From fec021b961d4148e7d918be15f3062facfe9b541 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 5 Jan 2022 09:47:11 +0000 Subject: [PATCH] CodeGen from PR 16715 in Azure/azure-rest-api-specs Schema resource added in REST API Spec for api-version 2021-08-01 (#16715) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adds base for updating Microsoft.ApiManagement from version preview/2021-01-01-preview to version 2021-04-01-preview * Updates readme * Updates API version in new specs and examples * Added support for GraphQL API type (#14851) * Added support for GraphQL API type * Added missing enum value for GraphQL APIs. * add schema definition fix from 2021-01-01-preview (#14883) Co-authored-by: Alan Feng * Vanguard: Get Outbound Network Dependency (#14900) * outbound dependency * fix resource * Update backup/restore API for managed identities (#14973) * Update backup/restore API for system-assigned and user-assigned identities * Fix formatting issue * Rename user-assigned-msi-client-id with client-id * SystemData implemenation on API Management Control Plane (#14899) * system-data * fix spec * remove unreferenced file * APIM - Network Watcher Connectivity Check integration specs (#15056) * Connectivity Check API Specs * Fix * Fix errors * style fixs * Fix 202 code * HTTPConnect request parameters * Fix errors Co-authored-by: Nicolás Barrera * Parameter examples added (#14836) * platformversion (#15114) * fix update service (#15478) * HttpConnect example (#15493) * HttpConnect example * Prettifier fix Co-authored-by: Nicolás Barrera * Rename from SchemaContract to ApiSchemaContract * apimschema.json added to last apim preview version * Completing specification for Schema resource. Fixing changes in SchemaContract. * Value field added to Schema resource specification. * path fixed. Renamed from ApiSchema to Schema. Adding suppression rule to readme.md Custom word added for spellcheck * Fixing PR observations. * Added properties of difference API spec format for "SchemaDocumentProperties" (#15703) * add schema definition fix from 2021-01-01-preview * added properties for SchemaDocumentProperties * updated the fix * updated fix * [APIM]Add private endpoint connection APIs (#15115) * Add private endpoint connection apis * add readme * quick fixes * fix to PE contract * Small fixes * small fixes * small fixes * Small fixes * small fixes * small fix * small fixes * small fixes * small fixes * Update readme.md * fix error * small fix * fix format * address comments * small fixes * Change to lower case * small fixes Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> * Adds base for updating Microsoft.ApiManagement from version preview/2021-04-01-preview to version 2021-08-01 * Updates readme * Updates API version in new specs and examples * Merge main * Modifications to Schema definition to add "description" field. Updating examples of Schema. * Fixing apimanagement.json * Prettier applied in files * Fixing PR comments * fixing x-ms-long-running-operation. * x-ms-long-running-operation : true in apischema. * Removing "Resource" type from apimanagement.json * Apimschema.json updated to point to types.json for ErrorResponse. * Merging from 2021-04-01-preview to 2021-08-01 stable version. * undoing change of responseBody * Updating ErrorResponse. * Fixing definitions merge. * Changing definitions to fix output of examples. * Changes in definitions * Updating response in some examples. * Rolling back ApiSchema -> Schema Schema -> GlobalSchema * Changes to undo apimapis.json and adding prefix for Global example Schemas. * Setting x-ms-long-running-operation-options to location. Co-authored-by: Samir Solanki Co-authored-by: Alexander Zaslonov Co-authored-by: DreamlessA Co-authored-by: Alan Feng Co-authored-by: Jatin Sanghvi <20547963+JatinSanghvi@users.noreply.github.com> Co-authored-by: Nicolás Barrera Co-authored-by: Nicolás Barrera Co-authored-by: VitaliyKurokhtin Co-authored-by: Christian Palomares Co-authored-by: RupengLiu Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- .../azure-mgmt-apimanagement/_meta.json | 10 +- .../azure/mgmt/apimanagement/__init__.py | 9 +- .../apimanagement/_api_management_client.py | 416 +- .../mgmt/apimanagement/_configuration.py | 21 +- .../azure/mgmt/apimanagement/_metadata.json | 58 +- .../azure/mgmt/apimanagement/_patch.py | 31 + .../azure/mgmt/apimanagement/_vendor.py | 27 + .../azure/mgmt/apimanagement/_version.py | 2 +- .../azure/mgmt/apimanagement/aio/__init__.py | 5 + .../aio/_api_management_client.py | 425 +- .../mgmt/apimanagement/aio/_configuration.py | 8 +- .../azure/mgmt/apimanagement/aio/_patch.py | 31 + .../apimanagement/aio/operations/__init__.py | 8 + .../operations/_api_diagnostic_operations.py | 304 +- .../aio/operations/_api_export_operations.py | 47 +- .../_api_issue_attachment_operations.py | 261 +- .../_api_issue_comment_operations.py | 261 +- .../aio/operations/_api_issue_operations.py | 308 +- .../_api_management_client_operations.py | 148 + .../_api_management_operations_operations.py | 47 +- .../_api_management_service_operations.py | 686 +- ..._api_management_service_skus_operations.py | 61 +- .../_api_management_skus_operations.py | 58 +- .../operations/_api_operation_operations.py | 305 +- .../_api_operation_policy_operations.py | 227 +- .../aio/operations/_api_operations.py | 409 +- .../aio/operations/_api_policy_operations.py | 218 +- .../aio/operations/_api_product_operations.py | 76 +- .../aio/operations/_api_release_operations.py | 304 +- .../operations/_api_revision_operations.py | 79 +- .../aio/operations/_api_schema_operations.py | 300 +- .../_api_tag_description_operations.py | 250 +- .../operations/_api_version_set_operations.py | 291 +- .../_authorization_server_operations.py | 327 +- .../aio/operations/_backend_operations.py | 334 +- .../aio/operations/_cache_operations.py | 284 +- .../aio/operations/_certificate_operations.py | 279 +- .../operations/_content_item_operations.py | 224 +- .../operations/_content_type_operations.py | 176 +- .../_delegation_settings_operations.py | 208 +- .../_deleted_services_operations.py | 155 +- .../aio/operations/_diagnostic_operations.py | 291 +- .../operations/_email_template_operations.py | 289 +- .../aio/operations/_gateway_api_operations.py | 197 +- ...ateway_certificate_authority_operations.py | 250 +- ...teway_hostname_configuration_operations.py | 250 +- .../aio/operations/_gateway_operations.py | 409 +- .../operations/_global_schema_operations.py | 462 + .../aio/operations/_group_operations.py | 288 +- .../aio/operations/_group_user_operations.py | 187 +- .../_identity_provider_operations.py | 315 +- .../aio/operations/_issue_operations.py | 109 +- .../aio/operations/_logger_operations.py | 288 +- .../aio/operations/_named_value_operations.py | 464 +- .../operations/_network_status_operations.py | 76 +- .../operations/_notification_operations.py | 145 +- ...notification_recipient_email_operations.py | 154 +- ..._notification_recipient_user_operations.py | 154 +- .../_open_id_connect_provider_operations.py | 327 +- .../aio/operations/_operation_operations.py | 83 +- ...twork_dependencies_endpoints_operations.py | 97 + .../_policy_description_operations.py | 44 +- .../aio/operations/_policy_operations.py | 207 +- .../operations/_portal_revision_operations.py | 317 +- .../operations/_portal_settings_operations.py | 41 +- ..._private_endpoint_connection_operations.py | 517 + .../aio/operations/_product_api_operations.py | 184 +- .../operations/_product_group_operations.py | 187 +- .../aio/operations/_product_operations.py | 370 +- .../operations/_product_policy_operations.py | 217 +- .../_product_subscriptions_operations.py | 79 +- .../_quota_by_counter_keys_operations.py | 86 +- .../_quota_by_period_keys_operations.py | 90 +- .../aio/operations/_region_operations.py | 61 +- .../aio/operations/_reports_operations.py | 543 +- .../_sign_in_settings_operations.py | 175 +- .../_sign_up_settings_operations.py | 175 +- .../operations/_subscription_operations.py | 407 +- .../aio/operations/_tag_operations.py | 944 +- .../operations/_tag_resource_operations.py | 76 +- .../_tenant_access_git_operations.py | 76 +- .../operations/_tenant_access_operations.py | 349 +- .../_tenant_configuration_operations.py | 274 +- .../operations/_tenant_settings_operations.py | 104 +- .../_user_confirmation_password_operations.py | 45 +- .../aio/operations/_user_group_operations.py | 76 +- .../operations/_user_identities_operations.py | 67 +- .../aio/operations/_user_operations.py | 386 +- .../_user_subscription_operations.py | 117 +- .../mgmt/apimanagement/models/__init__.py | 894 +- .../models/_api_management_client_enums.py | 310 +- .../mgmt/apimanagement/models/_models.py | 11933 ---------------- .../mgmt/apimanagement/models/_models_py3.py | 10946 ++++++++++---- .../mgmt/apimanagement/operations/__init__.py | 8 + .../operations/_api_diagnostic_operations.py | 673 +- .../operations/_api_export_operations.py | 116 +- .../_api_issue_attachment_operations.py | 586 +- .../_api_issue_comment_operations.py | 583 +- .../operations/_api_issue_operations.py | 688 +- .../_api_management_client_operations.py | 195 + .../_api_management_operations_operations.py | 85 +- .../_api_management_service_operations.py | 1328 +- ..._api_management_service_skus_operations.py | 113 +- .../_api_management_skus_operations.py | 102 +- .../operations/_api_operation_operations.py | 679 +- .../_api_operation_policy_operations.py | 543 +- .../operations/_api_operations.py | 849 +- .../operations/_api_policy_operations.py | 514 +- .../operations/_api_product_operations.py | 148 +- .../operations/_api_release_operations.py | 673 +- .../operations/_api_revision_operations.py | 151 +- .../operations/_api_schema_operations.py | 624 +- .../_api_tag_description_operations.py | 552 +- .../operations/_api_version_set_operations.py | 636 +- .../_authorization_server_operations.py | 723 +- .../operations/_backend_operations.py | 738 +- .../operations/_cache_operations.py | 624 +- .../operations/_certificate_operations.py | 614 +- .../operations/_content_item_operations.py | 499 +- .../operations/_content_type_operations.py | 383 +- .../_delegation_settings_operations.py | 472 +- .../_deleted_services_operations.py | 298 +- .../operations/_diagnostic_operations.py | 636 +- .../operations/_email_template_operations.py | 634 +- .../operations/_gateway_api_operations.py | 440 +- ...ateway_certificate_authority_operations.py | 555 +- ...teway_hostname_configuration_operations.py | 555 +- .../operations/_gateway_operations.py | 920 +- .../operations/_global_schema_operations.py | 670 + .../operations/_group_operations.py | 633 +- .../operations/_group_user_operations.py | 415 +- .../_identity_provider_operations.py | 692 +- .../operations/_issue_operations.py | 221 +- .../operations/_logger_operations.py | 633 +- .../operations/_named_value_operations.py | 951 +- .../operations/_network_status_operations.py | 180 +- .../operations/_notification_operations.py | 310 +- ...notification_recipient_email_operations.py | 370 +- ..._notification_recipient_user_operations.py | 370 +- .../_open_id_connect_provider_operations.py | 723 +- .../operations/_operation_operations.py | 160 +- ...twork_dependencies_endpoints_operations.py | 134 + .../_policy_description_operations.py | 106 +- .../operations/_policy_operations.py | 483 +- .../operations/_portal_revision_operations.py | 626 +- .../operations/_portal_settings_operations.py | 97 +- ..._private_endpoint_connection_operations.py | 746 + .../operations/_product_api_operations.py | 415 +- .../operations/_product_group_operations.py | 415 +- .../operations/_product_operations.py | 792 +- .../operations/_product_policy_operations.py | 513 +- .../_product_subscriptions_operations.py | 151 +- .../_quota_by_counter_keys_operations.py | 202 +- .../_quota_by_period_keys_operations.py | 214 +- .../operations/_region_operations.py | 113 +- .../operations/_reports_operations.py | 1036 +- .../_sign_in_settings_operations.py | 395 +- .../_sign_up_settings_operations.py | 395 +- .../operations/_subscription_operations.py | 916 +- .../operations/_tag_operations.py | 2133 ++- .../operations/_tag_resource_operations.py | 144 +- .../_tenant_access_git_operations.py | 184 +- .../operations/_tenant_access_operations.py | 777 +- .../_tenant_configuration_operations.py | 542 +- .../operations/_tenant_settings_operations.py | 206 +- .../_user_confirmation_password_operations.py | 111 +- .../operations/_user_group_operations.py | 148 +- .../operations/_user_identities_operations.py | 123 +- .../operations/_user_operations.py | 863 +- .../_user_subscription_operations.py | 237 +- 170 files changed, 43595 insertions(+), 36697 deletions(-) create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_patch.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_vendor.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_patch.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_client_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_global_schema_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_outbound_network_dependencies_endpoints_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_private_endpoint_connection_operations.py delete mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_client_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_global_schema_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_outbound_network_dependencies_endpoints_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_private_endpoint_connection_operations.py diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/_meta.json b/sdk/apimanagement/azure-mgmt-apimanagement/_meta.json index 99dfb3d4d5d73..88856baaee4ad 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/_meta.json +++ b/sdk/apimanagement/azure-mgmt-apimanagement/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "ecf0d999c9128ddfc1cac5ba52f57a5b00f94000", + "commit": "925e8285703ddd461588d8f5fbf14bd97c286fab", "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 --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "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", "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 2bdfd1fb98518..80f492a921b4f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/__init__.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ApiManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._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() 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 e8a9118accf76..460870e346404 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 @@ -6,95 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, 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 + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ApiManagementClientConfiguration -from .operations import ApiOperations -from .operations import ApiRevisionOperations -from .operations import ApiReleaseOperations -from .operations import ApiOperationOperations -from .operations import ApiOperationPolicyOperations -from .operations import TagOperations -from .operations import ApiProductOperations -from .operations import ApiPolicyOperations -from .operations import ApiSchemaOperations -from .operations import ApiDiagnosticOperations -from .operations import ApiIssueOperations -from .operations import ApiIssueCommentOperations -from .operations import ApiIssueAttachmentOperations -from .operations import ApiTagDescriptionOperations -from .operations import OperationOperations -from .operations import ApiExportOperations -from .operations import ApiVersionSetOperations -from .operations import AuthorizationServerOperations -from .operations import BackendOperations -from .operations import CacheOperations -from .operations import CertificateOperations -from .operations import ContentTypeOperations -from .operations import ContentItemOperations -from .operations import DeletedServicesOperations -from .operations import ApiManagementOperationsOperations -from .operations import ApiManagementServiceSkusOperations -from .operations import ApiManagementServiceOperations -from .operations import DiagnosticOperations -from .operations import EmailTemplateOperations -from .operations import GatewayOperations -from .operations import GatewayHostnameConfigurationOperations -from .operations import GatewayApiOperations -from .operations import GatewayCertificateAuthorityOperations -from .operations import GroupOperations -from .operations import GroupUserOperations -from .operations import IdentityProviderOperations -from .operations import IssueOperations -from .operations import LoggerOperations -from .operations import NamedValueOperations -from .operations import NetworkStatusOperations -from .operations import NotificationOperations -from .operations import NotificationRecipientUserOperations -from .operations import NotificationRecipientEmailOperations -from .operations import OpenIdConnectProviderOperations -from .operations import PolicyOperations -from .operations import PolicyDescriptionOperations -from .operations import PortalRevisionOperations -from .operations import PortalSettingsOperations -from .operations import SignInSettingsOperations -from .operations import SignUpSettingsOperations -from .operations import DelegationSettingsOperations -from .operations import ProductOperations -from .operations import ProductApiOperations -from .operations import ProductGroupOperations -from .operations import ProductSubscriptionsOperations -from .operations import ProductPolicyOperations -from .operations import QuotaByCounterKeysOperations -from .operations import QuotaByPeriodKeysOperations -from .operations import RegionOperations -from .operations import ReportsOperations -from .operations import TenantSettingsOperations -from .operations import ApiManagementSkusOperations -from .operations import SubscriptionOperations -from .operations import TagResourceOperations -from .operations import TenantAccessOperations -from .operations import TenantAccessGitOperations -from .operations import TenantConfigurationOperations -from .operations import UserOperations -from .operations import UserGroupOperations -from .operations import UserSubscriptionOperations -from .operations import UserIdentitiesOperations -from .operations import UserConfirmationPasswordOperations -from . import models - -class ApiManagementClient(object): +class ApiManagementClient(ApiManagementClientOperationsMixin): """ApiManagement Client. :ivar api: ApiOperations operations @@ -132,7 +59,8 @@ class ApiManagementClient(object): :ivar api_version_set: ApiVersionSetOperations operations :vartype api_version_set: azure.mgmt.apimanagement.operations.ApiVersionSetOperations :ivar authorization_server: AuthorizationServerOperations operations - :vartype authorization_server: azure.mgmt.apimanagement.operations.AuthorizationServerOperations + :vartype authorization_server: + azure.mgmt.apimanagement.operations.AuthorizationServerOperations :ivar backend: BackendOperations operations :vartype backend: azure.mgmt.apimanagement.operations.BackendOperations :ivar cache: CacheOperations operations @@ -146,11 +74,14 @@ class ApiManagementClient(object): :ivar deleted_services: DeletedServicesOperations operations :vartype deleted_services: azure.mgmt.apimanagement.operations.DeletedServicesOperations :ivar api_management_operations: ApiManagementOperationsOperations operations - :vartype api_management_operations: azure.mgmt.apimanagement.operations.ApiManagementOperationsOperations + :vartype api_management_operations: + azure.mgmt.apimanagement.operations.ApiManagementOperationsOperations :ivar api_management_service_skus: ApiManagementServiceSkusOperations operations - :vartype api_management_service_skus: azure.mgmt.apimanagement.operations.ApiManagementServiceSkusOperations + :vartype api_management_service_skus: + azure.mgmt.apimanagement.operations.ApiManagementServiceSkusOperations :ivar api_management_service: ApiManagementServiceOperations operations - :vartype api_management_service: azure.mgmt.apimanagement.operations.ApiManagementServiceOperations + :vartype api_management_service: + azure.mgmt.apimanagement.operations.ApiManagementServiceOperations :ivar diagnostic: DiagnosticOperations operations :vartype diagnostic: azure.mgmt.apimanagement.operations.DiagnosticOperations :ivar email_template: EmailTemplateOperations operations @@ -158,11 +89,13 @@ class ApiManagementClient(object): :ivar gateway: GatewayOperations operations :vartype gateway: azure.mgmt.apimanagement.operations.GatewayOperations :ivar gateway_hostname_configuration: GatewayHostnameConfigurationOperations operations - :vartype gateway_hostname_configuration: azure.mgmt.apimanagement.operations.GatewayHostnameConfigurationOperations + :vartype gateway_hostname_configuration: + azure.mgmt.apimanagement.operations.GatewayHostnameConfigurationOperations :ivar gateway_api: GatewayApiOperations operations :vartype gateway_api: azure.mgmt.apimanagement.operations.GatewayApiOperations :ivar gateway_certificate_authority: GatewayCertificateAuthorityOperations operations - :vartype gateway_certificate_authority: azure.mgmt.apimanagement.operations.GatewayCertificateAuthorityOperations + :vartype gateway_certificate_authority: + azure.mgmt.apimanagement.operations.GatewayCertificateAuthorityOperations :ivar group: GroupOperations operations :vartype group: azure.mgmt.apimanagement.operations.GroupOperations :ivar group_user: GroupUserOperations operations @@ -180,11 +113,18 @@ class ApiManagementClient(object): :ivar notification: NotificationOperations operations :vartype notification: azure.mgmt.apimanagement.operations.NotificationOperations :ivar notification_recipient_user: NotificationRecipientUserOperations operations - :vartype notification_recipient_user: azure.mgmt.apimanagement.operations.NotificationRecipientUserOperations + :vartype notification_recipient_user: + azure.mgmt.apimanagement.operations.NotificationRecipientUserOperations :ivar notification_recipient_email: NotificationRecipientEmailOperations operations - :vartype notification_recipient_email: azure.mgmt.apimanagement.operations.NotificationRecipientEmailOperations + :vartype notification_recipient_email: + azure.mgmt.apimanagement.operations.NotificationRecipientEmailOperations :ivar open_id_connect_provider: OpenIdConnectProviderOperations operations - :vartype open_id_connect_provider: azure.mgmt.apimanagement.operations.OpenIdConnectProviderOperations + :vartype open_id_connect_provider: + azure.mgmt.apimanagement.operations.OpenIdConnectProviderOperations + :ivar outbound_network_dependencies_endpoints: OutboundNetworkDependenciesEndpointsOperations + operations + :vartype outbound_network_dependencies_endpoints: + azure.mgmt.apimanagement.operations.OutboundNetworkDependenciesEndpointsOperations :ivar policy: PolicyOperations operations :vartype policy: azure.mgmt.apimanagement.operations.PolicyOperations :ivar policy_description: PolicyDescriptionOperations operations @@ -199,6 +139,9 @@ class ApiManagementClient(object): :vartype sign_up_settings: azure.mgmt.apimanagement.operations.SignUpSettingsOperations :ivar delegation_settings: DelegationSettingsOperations operations :vartype delegation_settings: azure.mgmt.apimanagement.operations.DelegationSettingsOperations + :ivar private_endpoint_connection: PrivateEndpointConnectionOperations operations + :vartype private_endpoint_connection: + azure.mgmt.apimanagement.operations.PrivateEndpointConnectionOperations :ivar product: ProductOperations operations :vartype product: azure.mgmt.apimanagement.operations.ProductOperations :ivar product_api: ProductApiOperations operations @@ -206,17 +149,21 @@ class ApiManagementClient(object): :ivar product_group: ProductGroupOperations operations :vartype product_group: azure.mgmt.apimanagement.operations.ProductGroupOperations :ivar product_subscriptions: ProductSubscriptionsOperations operations - :vartype product_subscriptions: azure.mgmt.apimanagement.operations.ProductSubscriptionsOperations + :vartype product_subscriptions: + azure.mgmt.apimanagement.operations.ProductSubscriptionsOperations :ivar product_policy: ProductPolicyOperations operations :vartype product_policy: azure.mgmt.apimanagement.operations.ProductPolicyOperations :ivar quota_by_counter_keys: QuotaByCounterKeysOperations operations - :vartype quota_by_counter_keys: azure.mgmt.apimanagement.operations.QuotaByCounterKeysOperations + :vartype quota_by_counter_keys: + azure.mgmt.apimanagement.operations.QuotaByCounterKeysOperations :ivar quota_by_period_keys: QuotaByPeriodKeysOperations operations :vartype quota_by_period_keys: azure.mgmt.apimanagement.operations.QuotaByPeriodKeysOperations :ivar region: RegionOperations operations :vartype region: azure.mgmt.apimanagement.operations.RegionOperations :ivar reports: ReportsOperations operations :vartype reports: azure.mgmt.apimanagement.operations.ReportsOperations + :ivar global_schema: GlobalSchemaOperations operations + :vartype global_schema: azure.mgmt.apimanagement.operations.GlobalSchemaOperations :ivar tenant_settings: TenantSettingsOperations operations :vartype tenant_settings: azure.mgmt.apimanagement.operations.TenantSettingsOperations :ivar api_management_skus: ApiManagementSkusOperations operations @@ -230,7 +177,8 @@ class ApiManagementClient(object): :ivar tenant_access_git: TenantAccessGitOperations operations :vartype tenant_access_git: azure.mgmt.apimanagement.operations.TenantAccessGitOperations :ivar tenant_configuration: TenantConfigurationOperations operations - :vartype tenant_configuration: azure.mgmt.apimanagement.operations.TenantConfigurationOperations + :vartype tenant_configuration: + azure.mgmt.apimanagement.operations.TenantConfigurationOperations :ivar user: UserOperations operations :vartype user: azure.mgmt.apimanagement.operations.UserOperations :ivar user_group: UserGroupOperations operations @@ -240,195 +188,135 @@ class ApiManagementClient(object): :ivar user_identities: UserIdentitiesOperations operations :vartype user_identities: azure.mgmt.apimanagement.operations.UserIdentitiesOperations :ivar user_confirmation_password: UserConfirmationPasswordOperations operations - :vartype user_confirmation_password: azure.mgmt.apimanagement.operations.UserConfirmationPasswordOperations + :vartype user_confirmation_password: + azure.mgmt.apimanagement.operations.UserConfirmationPasswordOperations :param credential: Credential needed for the client to connect to Azure. :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. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApiManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.api = ApiOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_revision = ApiRevisionOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_release = ApiReleaseOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_operation = ApiOperationOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_operation_policy = ApiOperationPolicyOperations(self._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.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.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.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_api = GatewayApiOperations(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.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.policy = PolicyOperations(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.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_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.region = RegionOperations(self._client, self._config, self._serialize, self._deserialize) + self.reports = ReportsOperations(self._client, self._config, self._serialize, self._deserialize) + self.global_schema = GlobalSchemaOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenant_settings = TenantSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_management_skus = ApiManagementSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscription = SubscriptionOperations(self._client, self._config, self._serialize, self._deserialize) + self.tag_resource = TagResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.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.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_identities = UserIdentitiesOperations(self._client, self._config, self._serialize, self._deserialize) + self.user_confirmation_password = UserConfirmationPasswordOperations(self._client, self._config, self._serialize, self._deserialize) - self.api = ApiOperations( - self._client, self._config, self._serialize, self._deserialize) - self.api_revision = ApiRevisionOperations( - self._client, self._config, self._serialize, self._deserialize) - self.api_release = ApiReleaseOperations( - self._client, self._config, self._serialize, self._deserialize) - self.api_operation = ApiOperationOperations( - self._client, self._config, self._serialize, self._deserialize) - self.api_operation_policy = ApiOperationPolicyOperations( - self._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.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.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.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_api = GatewayApiOperations( - 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.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.policy = PolicyOperations( - 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.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_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.region = RegionOperations( - self._client, self._config, self._serialize, self._deserialize) - self.reports = ReportsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenant_settings = TenantSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.api_management_skus = ApiManagementSkusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscription = SubscriptionOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tag_resource = TagResourceOperations( - self._client, self._config, self._serialize, self._deserialize) - self.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.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_identities = UserIdentitiesOperations( - 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, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_configuration.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_configuration.py index 38989b8ec5c49..6644ed21cee1b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_configuration.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,20 +33,19 @@ class ApiManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ApiManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApiManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-12-01" + 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._configure(**kwargs) @@ -68,4 +65,4 @@ def _configure( 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 = policies.BearerTokenCredentialPolicy(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 index 1e090b9998aa9..9e09698b6a8f4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_metadata.json +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_metadata.json @@ -1,17 +1,17 @@ { - "chosen_version": "2020-12-01", - "total_api_version_list": ["2020-12-01"], + "chosen_version": "2021-08-01", + "total_api_version_list": ["2021-08-01"], "client": { "name": "ApiManagementClient", "filename": "_api_management_client", "description": "ApiManagement Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApiManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"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\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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", @@ -142,6 +141,7 @@ "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", @@ -149,6 +149,7 @@ "sign_in_settings": "SignInSettingsOperations", "sign_up_settings": "SignUpSettingsOperations", "delegation_settings": "DelegationSettingsOperations", + "private_endpoint_connection": "PrivateEndpointConnectionOperations", "product": "ProductOperations", "product_api": "ProductApiOperations", "product_group": "ProductGroupOperations", @@ -158,6 +159,7 @@ "quota_by_period_keys": "QuotaByPeriodKeysOperations", "region": "RegionOperations", "reports": "ReportsOperations", + "global_schema": "GlobalSchemaOperations", "tenant_settings": "TenantSettingsOperations", "api_management_skus": "ApiManagementSkusOperations", "subscription": "SubscriptionOperations", @@ -170,5 +172,35 @@ "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:\n ~azure.mgmt.apimanagement.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: ~azure.mgmt.apimanagement.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:\n ~azure.mgmt.apimanagement.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: ~azure.mgmt.apimanagement.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:\n ~azure.mgmt.apimanagement.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:\n ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.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:\n ~azure.mgmt.apimanagement.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[~azure.mgmt.apimanagement.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 new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# 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 diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_vendor.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + 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 + ] + template = "/".join(components) 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 83f24ab509461..eae7c95b6fbdb 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 = "2.1.0" +VERSION = "0.1.0" 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 8ef78e4dcbb06..bed0fab90ba8a 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 @@ -8,3 +8,8 @@ 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() 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 3c2ffc6bfec3e..790bc9e17c2bf 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 @@ -6,93 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient 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 + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ApiManagementClientConfiguration -from .operations import ApiOperations -from .operations import ApiRevisionOperations -from .operations import ApiReleaseOperations -from .operations import ApiOperationOperations -from .operations import ApiOperationPolicyOperations -from .operations import TagOperations -from .operations import ApiProductOperations -from .operations import ApiPolicyOperations -from .operations import ApiSchemaOperations -from .operations import ApiDiagnosticOperations -from .operations import ApiIssueOperations -from .operations import ApiIssueCommentOperations -from .operations import ApiIssueAttachmentOperations -from .operations import ApiTagDescriptionOperations -from .operations import OperationOperations -from .operations import ApiExportOperations -from .operations import ApiVersionSetOperations -from .operations import AuthorizationServerOperations -from .operations import BackendOperations -from .operations import CacheOperations -from .operations import CertificateOperations -from .operations import ContentTypeOperations -from .operations import ContentItemOperations -from .operations import DeletedServicesOperations -from .operations import ApiManagementOperationsOperations -from .operations import ApiManagementServiceSkusOperations -from .operations import ApiManagementServiceOperations -from .operations import DiagnosticOperations -from .operations import EmailTemplateOperations -from .operations import GatewayOperations -from .operations import GatewayHostnameConfigurationOperations -from .operations import GatewayApiOperations -from .operations import GatewayCertificateAuthorityOperations -from .operations import GroupOperations -from .operations import GroupUserOperations -from .operations import IdentityProviderOperations -from .operations import IssueOperations -from .operations import LoggerOperations -from .operations import NamedValueOperations -from .operations import NetworkStatusOperations -from .operations import NotificationOperations -from .operations import NotificationRecipientUserOperations -from .operations import NotificationRecipientEmailOperations -from .operations import OpenIdConnectProviderOperations -from .operations import PolicyOperations -from .operations import PolicyDescriptionOperations -from .operations import PortalRevisionOperations -from .operations import PortalSettingsOperations -from .operations import SignInSettingsOperations -from .operations import SignUpSettingsOperations -from .operations import DelegationSettingsOperations -from .operations import ProductOperations -from .operations import ProductApiOperations -from .operations import ProductGroupOperations -from .operations import ProductSubscriptionsOperations -from .operations import ProductPolicyOperations -from .operations import QuotaByCounterKeysOperations -from .operations import QuotaByPeriodKeysOperations -from .operations import RegionOperations -from .operations import ReportsOperations -from .operations import TenantSettingsOperations -from .operations import ApiManagementSkusOperations -from .operations import SubscriptionOperations -from .operations import TagResourceOperations -from .operations import TenantAccessOperations -from .operations import TenantAccessGitOperations -from .operations import TenantConfigurationOperations -from .operations import UserOperations -from .operations import UserGroupOperations -from .operations import UserSubscriptionOperations -from .operations import UserIdentitiesOperations -from .operations import UserConfirmationPasswordOperations -from .. import models - - -class ApiManagementClient(object): +class ApiManagementClient(ApiManagementClientOperationsMixin): """ApiManagement Client. :ivar api: ApiOperations operations @@ -104,7 +33,8 @@ class ApiManagementClient(object): :ivar api_operation: ApiOperationOperations operations :vartype api_operation: azure.mgmt.apimanagement.aio.operations.ApiOperationOperations :ivar api_operation_policy: ApiOperationPolicyOperations operations - :vartype api_operation_policy: azure.mgmt.apimanagement.aio.operations.ApiOperationPolicyOperations + :vartype api_operation_policy: + azure.mgmt.apimanagement.aio.operations.ApiOperationPolicyOperations :ivar tag: TagOperations operations :vartype tag: azure.mgmt.apimanagement.aio.operations.TagOperations :ivar api_product: ApiProductOperations operations @@ -120,9 +50,11 @@ class ApiManagementClient(object): :ivar api_issue_comment: ApiIssueCommentOperations operations :vartype api_issue_comment: azure.mgmt.apimanagement.aio.operations.ApiIssueCommentOperations :ivar api_issue_attachment: ApiIssueAttachmentOperations operations - :vartype api_issue_attachment: azure.mgmt.apimanagement.aio.operations.ApiIssueAttachmentOperations + :vartype api_issue_attachment: + azure.mgmt.apimanagement.aio.operations.ApiIssueAttachmentOperations :ivar api_tag_description: ApiTagDescriptionOperations operations - :vartype api_tag_description: azure.mgmt.apimanagement.aio.operations.ApiTagDescriptionOperations + :vartype api_tag_description: + azure.mgmt.apimanagement.aio.operations.ApiTagDescriptionOperations :ivar operation: OperationOperations operations :vartype operation: azure.mgmt.apimanagement.aio.operations.OperationOperations :ivar api_export: ApiExportOperations operations @@ -130,7 +62,8 @@ class ApiManagementClient(object): :ivar api_version_set: ApiVersionSetOperations operations :vartype api_version_set: azure.mgmt.apimanagement.aio.operations.ApiVersionSetOperations :ivar authorization_server: AuthorizationServerOperations operations - :vartype authorization_server: azure.mgmt.apimanagement.aio.operations.AuthorizationServerOperations + :vartype authorization_server: + azure.mgmt.apimanagement.aio.operations.AuthorizationServerOperations :ivar backend: BackendOperations operations :vartype backend: azure.mgmt.apimanagement.aio.operations.BackendOperations :ivar cache: CacheOperations operations @@ -144,11 +77,14 @@ class ApiManagementClient(object): :ivar deleted_services: DeletedServicesOperations operations :vartype deleted_services: azure.mgmt.apimanagement.aio.operations.DeletedServicesOperations :ivar api_management_operations: ApiManagementOperationsOperations operations - :vartype api_management_operations: azure.mgmt.apimanagement.aio.operations.ApiManagementOperationsOperations + :vartype api_management_operations: + azure.mgmt.apimanagement.aio.operations.ApiManagementOperationsOperations :ivar api_management_service_skus: ApiManagementServiceSkusOperations operations - :vartype api_management_service_skus: azure.mgmt.apimanagement.aio.operations.ApiManagementServiceSkusOperations + :vartype api_management_service_skus: + azure.mgmt.apimanagement.aio.operations.ApiManagementServiceSkusOperations :ivar api_management_service: ApiManagementServiceOperations operations - :vartype api_management_service: azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations + :vartype api_management_service: + azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations :ivar diagnostic: DiagnosticOperations operations :vartype diagnostic: azure.mgmt.apimanagement.aio.operations.DiagnosticOperations :ivar email_template: EmailTemplateOperations operations @@ -156,11 +92,13 @@ class ApiManagementClient(object): :ivar gateway: GatewayOperations operations :vartype gateway: azure.mgmt.apimanagement.aio.operations.GatewayOperations :ivar gateway_hostname_configuration: GatewayHostnameConfigurationOperations operations - :vartype gateway_hostname_configuration: azure.mgmt.apimanagement.aio.operations.GatewayHostnameConfigurationOperations + :vartype gateway_hostname_configuration: + azure.mgmt.apimanagement.aio.operations.GatewayHostnameConfigurationOperations :ivar gateway_api: GatewayApiOperations operations :vartype gateway_api: azure.mgmt.apimanagement.aio.operations.GatewayApiOperations :ivar gateway_certificate_authority: GatewayCertificateAuthorityOperations operations - :vartype gateway_certificate_authority: azure.mgmt.apimanagement.aio.operations.GatewayCertificateAuthorityOperations + :vartype gateway_certificate_authority: + azure.mgmt.apimanagement.aio.operations.GatewayCertificateAuthorityOperations :ivar group: GroupOperations operations :vartype group: azure.mgmt.apimanagement.aio.operations.GroupOperations :ivar group_user: GroupUserOperations operations @@ -178,15 +116,23 @@ class ApiManagementClient(object): :ivar notification: NotificationOperations operations :vartype notification: azure.mgmt.apimanagement.aio.operations.NotificationOperations :ivar notification_recipient_user: NotificationRecipientUserOperations operations - :vartype notification_recipient_user: azure.mgmt.apimanagement.aio.operations.NotificationRecipientUserOperations + :vartype notification_recipient_user: + azure.mgmt.apimanagement.aio.operations.NotificationRecipientUserOperations :ivar notification_recipient_email: NotificationRecipientEmailOperations operations - :vartype notification_recipient_email: azure.mgmt.apimanagement.aio.operations.NotificationRecipientEmailOperations + :vartype notification_recipient_email: + azure.mgmt.apimanagement.aio.operations.NotificationRecipientEmailOperations :ivar open_id_connect_provider: OpenIdConnectProviderOperations operations - :vartype open_id_connect_provider: azure.mgmt.apimanagement.aio.operations.OpenIdConnectProviderOperations + :vartype open_id_connect_provider: + azure.mgmt.apimanagement.aio.operations.OpenIdConnectProviderOperations + :ivar outbound_network_dependencies_endpoints: OutboundNetworkDependenciesEndpointsOperations + operations + :vartype outbound_network_dependencies_endpoints: + azure.mgmt.apimanagement.aio.operations.OutboundNetworkDependenciesEndpointsOperations :ivar policy: PolicyOperations operations :vartype policy: azure.mgmt.apimanagement.aio.operations.PolicyOperations :ivar policy_description: PolicyDescriptionOperations operations - :vartype policy_description: azure.mgmt.apimanagement.aio.operations.PolicyDescriptionOperations + :vartype policy_description: + azure.mgmt.apimanagement.aio.operations.PolicyDescriptionOperations :ivar portal_revision: PortalRevisionOperations operations :vartype portal_revision: azure.mgmt.apimanagement.aio.operations.PortalRevisionOperations :ivar portal_settings: PortalSettingsOperations operations @@ -196,7 +142,11 @@ class ApiManagementClient(object): :ivar sign_up_settings: SignUpSettingsOperations operations :vartype sign_up_settings: azure.mgmt.apimanagement.aio.operations.SignUpSettingsOperations :ivar delegation_settings: DelegationSettingsOperations operations - :vartype delegation_settings: azure.mgmt.apimanagement.aio.operations.DelegationSettingsOperations + :vartype delegation_settings: + azure.mgmt.apimanagement.aio.operations.DelegationSettingsOperations + :ivar private_endpoint_connection: PrivateEndpointConnectionOperations operations + :vartype private_endpoint_connection: + azure.mgmt.apimanagement.aio.operations.PrivateEndpointConnectionOperations :ivar product: ProductOperations operations :vartype product: azure.mgmt.apimanagement.aio.operations.ProductOperations :ivar product_api: ProductApiOperations operations @@ -204,21 +154,27 @@ class ApiManagementClient(object): :ivar product_group: ProductGroupOperations operations :vartype product_group: azure.mgmt.apimanagement.aio.operations.ProductGroupOperations :ivar product_subscriptions: ProductSubscriptionsOperations operations - :vartype product_subscriptions: azure.mgmt.apimanagement.aio.operations.ProductSubscriptionsOperations + :vartype product_subscriptions: + azure.mgmt.apimanagement.aio.operations.ProductSubscriptionsOperations :ivar product_policy: ProductPolicyOperations operations :vartype product_policy: azure.mgmt.apimanagement.aio.operations.ProductPolicyOperations :ivar quota_by_counter_keys: QuotaByCounterKeysOperations operations - :vartype quota_by_counter_keys: azure.mgmt.apimanagement.aio.operations.QuotaByCounterKeysOperations + :vartype quota_by_counter_keys: + azure.mgmt.apimanagement.aio.operations.QuotaByCounterKeysOperations :ivar quota_by_period_keys: QuotaByPeriodKeysOperations operations - :vartype quota_by_period_keys: azure.mgmt.apimanagement.aio.operations.QuotaByPeriodKeysOperations + :vartype quota_by_period_keys: + azure.mgmt.apimanagement.aio.operations.QuotaByPeriodKeysOperations :ivar region: RegionOperations operations :vartype region: azure.mgmt.apimanagement.aio.operations.RegionOperations :ivar reports: ReportsOperations operations :vartype reports: azure.mgmt.apimanagement.aio.operations.ReportsOperations + :ivar global_schema: GlobalSchemaOperations operations + :vartype global_schema: azure.mgmt.apimanagement.aio.operations.GlobalSchemaOperations :ivar tenant_settings: TenantSettingsOperations operations :vartype tenant_settings: azure.mgmt.apimanagement.aio.operations.TenantSettingsOperations :ivar api_management_skus: ApiManagementSkusOperations operations - :vartype api_management_skus: azure.mgmt.apimanagement.aio.operations.ApiManagementSkusOperations + :vartype api_management_skus: + azure.mgmt.apimanagement.aio.operations.ApiManagementSkusOperations :ivar subscription: SubscriptionOperations operations :vartype subscription: azure.mgmt.apimanagement.aio.operations.SubscriptionOperations :ivar tag_resource: TagResourceOperations operations @@ -228,7 +184,8 @@ class ApiManagementClient(object): :ivar tenant_access_git: TenantAccessGitOperations operations :vartype tenant_access_git: azure.mgmt.apimanagement.aio.operations.TenantAccessGitOperations :ivar tenant_configuration: TenantConfigurationOperations operations - :vartype tenant_configuration: azure.mgmt.apimanagement.aio.operations.TenantConfigurationOperations + :vartype tenant_configuration: + azure.mgmt.apimanagement.aio.operations.TenantConfigurationOperations :ivar user: UserOperations operations :vartype user: azure.mgmt.apimanagement.aio.operations.UserOperations :ivar user_group: UserGroupOperations operations @@ -238,193 +195,135 @@ class ApiManagementClient(object): :ivar user_identities: UserIdentitiesOperations operations :vartype user_identities: azure.mgmt.apimanagement.aio.operations.UserIdentitiesOperations :ivar user_confirmation_password: UserConfirmationPasswordOperations operations - :vartype user_confirmation_password: azure.mgmt.apimanagement.aio.operations.UserConfirmationPasswordOperations + :vartype user_confirmation_password: + azure.mgmt.apimanagement.aio.operations.UserConfirmationPasswordOperations :param credential: Credential needed for the client to connect to Azure. :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. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ApiManagementClientConfiguration(credential, 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)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.api = ApiOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_revision = ApiRevisionOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_release = ApiReleaseOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_operation = ApiOperationOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_operation_policy = ApiOperationPolicyOperations(self._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.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.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.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_api = GatewayApiOperations(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.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.policy = PolicyOperations(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.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_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.region = RegionOperations(self._client, self._config, self._serialize, self._deserialize) + self.reports = ReportsOperations(self._client, self._config, self._serialize, self._deserialize) + self.global_schema = GlobalSchemaOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenant_settings = TenantSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_management_skus = ApiManagementSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscription = SubscriptionOperations(self._client, self._config, self._serialize, self._deserialize) + self.tag_resource = TagResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.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.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_identities = UserIdentitiesOperations(self._client, self._config, self._serialize, self._deserialize) + self.user_confirmation_password = UserConfirmationPasswordOperations(self._client, self._config, self._serialize, self._deserialize) - self.api = ApiOperations( - self._client, self._config, self._serialize, self._deserialize) - self.api_revision = ApiRevisionOperations( - self._client, self._config, self._serialize, self._deserialize) - self.api_release = ApiReleaseOperations( - self._client, self._config, self._serialize, self._deserialize) - self.api_operation = ApiOperationOperations( - self._client, self._config, self._serialize, self._deserialize) - self.api_operation_policy = ApiOperationPolicyOperations( - self._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.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.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.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_api = GatewayApiOperations( - 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.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.policy = PolicyOperations( - 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.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_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.region = RegionOperations( - self._client, self._config, self._serialize, self._deserialize) - self.reports = ReportsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tenant_settings = TenantSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.api_management_skus = ApiManagementSkusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscription = SubscriptionOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tag_resource = TagResourceOperations( - self._client, self._config, self._serialize, self._deserialize) - self.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.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_identities = UserIdentitiesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.user_confirmation_password = UserConfirmationPasswordOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() 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 4e5bc34cdd4fc..d049edf46f0ab 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 @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,15 +37,15 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ApiManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(ApiManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-12-01" + 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._configure(**kwargs) @@ -64,4 +64,4 @@ def _configure( 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 = policies.AsyncBearerTokenCredentialPolicy(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 new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# 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 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 cd77fa38b0bab..9f8b6482fabbe 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 @@ -27,6 +27,7 @@ from ._backend_operations import BackendOperations from ._cache_operations import CacheOperations from ._certificate_operations import CertificateOperations +from ._api_management_client_operations import ApiManagementClientOperationsMixin from ._content_type_operations import ContentTypeOperations from ._content_item_operations import ContentItemOperations from ._deleted_services_operations import DeletedServicesOperations @@ -50,6 +51,7 @@ from ._notification_recipient_user_operations import NotificationRecipientUserOperations from ._notification_recipient_email_operations import NotificationRecipientEmailOperations from ._open_id_connect_provider_operations import OpenIdConnectProviderOperations +from ._outbound_network_dependencies_endpoints_operations import OutboundNetworkDependenciesEndpointsOperations from ._policy_operations import PolicyOperations from ._policy_description_operations import PolicyDescriptionOperations from ._portal_revision_operations import PortalRevisionOperations @@ -57,6 +59,7 @@ from ._sign_in_settings_operations import SignInSettingsOperations from ._sign_up_settings_operations import SignUpSettingsOperations from ._delegation_settings_operations import DelegationSettingsOperations +from ._private_endpoint_connection_operations import PrivateEndpointConnectionOperations from ._product_operations import ProductOperations from ._product_api_operations import ProductApiOperations from ._product_group_operations import ProductGroupOperations @@ -66,6 +69,7 @@ from ._quota_by_period_keys_operations import QuotaByPeriodKeysOperations from ._region_operations import RegionOperations from ._reports_operations import ReportsOperations +from ._global_schema_operations import GlobalSchemaOperations from ._tenant_settings_operations import TenantSettingsOperations from ._api_management_skus_operations import ApiManagementSkusOperations from ._subscription_operations import SubscriptionOperations @@ -101,6 +105,7 @@ 'BackendOperations', 'CacheOperations', 'CertificateOperations', + 'ApiManagementClientOperationsMixin', 'ContentTypeOperations', 'ContentItemOperations', 'DeletedServicesOperations', @@ -124,6 +129,7 @@ 'NotificationRecipientUserOperations', 'NotificationRecipientEmailOperations', 'OpenIdConnectProviderOperations', + 'OutboundNetworkDependenciesEndpointsOperations', 'PolicyOperations', 'PolicyDescriptionOperations', 'PortalRevisionOperations', @@ -131,6 +137,7 @@ 'SignInSettingsOperations', 'SignUpSettingsOperations', 'DelegationSettingsOperations', + 'PrivateEndpointConnectionOperations', 'ProductOperations', 'ProductApiOperations', 'ProductGroupOperations', @@ -140,6 +147,7 @@ 'QuotaByPeriodKeysOperations', 'RegionOperations', 'ReportsOperations', + 'GlobalSchemaOperations', 'TenantSettingsOperations', 'ApiManagementSkusOperations', 'SubscriptionOperations', 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 4c25c494f7320..607a08db78a13 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -68,8 +74,10 @@ def list_by_service( :param skip: Number of records to skip. :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.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DiagnosticCollection] + :return: An iterator like instance of either DiagnosticCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DiagnosticCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticCollection"] @@ -77,43 +85,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DiagnosticCollection', pipeline_response) + deserialized = self._deserialize("DiagnosticCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -126,17 +132,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -166,46 +174,39 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -235,47 +236,41 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -312,59 +307,53 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DiagnosticContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DiagnosticContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -401,53 +390,47 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DiagnosticContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DiagnosticContract') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -481,39 +464,30 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 453c7694850bf..2ab48b2659640 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 @@ -5,16 +5,20 @@ # 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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -74,36 +79,26 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['format'] = self._serialize.query("format", format, 'str') - query_parameters['export'] = self._serialize.query("export", export, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + format=format, + export=export, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApiExportResult', pipeline_response) @@ -112,4 +107,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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 36001d53d5f52..fd23c178d12e4 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -73,8 +79,10 @@ def list_by_service( :param skip: Number of records to skip. :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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueAttachmentCollection] + :return: An iterator like instance of either IssueAttachmentCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueAttachmentCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueAttachmentCollection"] @@ -82,44 +90,43 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IssueAttachmentCollection', pipeline_response) + deserialized = self._deserialize("IssueAttachmentCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -132,17 +139,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -177,47 +186,40 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + attachment_id=attachment_id, + subscription_id=self._config.subscription_id, + template_url=self.get_entity_tag.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -251,48 +253,42 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + attachment_id=attachment_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueAttachmentContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -333,60 +329,54 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'IssueAttachmentContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'IssueAttachmentContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + attachment_id=attachment_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -424,40 +414,31 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + attachment_id=attachment_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 386dbb118f68c..5db9f3354de0c 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -73,8 +79,10 @@ def list_by_service( :param skip: Number of records to skip. :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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueCommentCollection] + :return: An iterator like instance of either IssueCommentCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueCommentCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCommentCollection"] @@ -82,44 +90,43 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IssueCommentCollection', pipeline_response) + deserialized = self._deserialize("IssueCommentCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -132,17 +139,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -176,47 +185,40 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'commentId': self._serialize.url("comment_id", comment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + comment_id=comment_id, + subscription_id=self._config.subscription_id, + template_url=self.get_entity_tag.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -249,48 +251,42 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'commentId': self._serialize.url("comment_id", comment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + comment_id=comment_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueCommentContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -330,60 +326,54 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'commentId': self._serialize.url("comment_id", comment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'IssueCommentContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'IssueCommentContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + comment_id=comment_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -420,40 +410,31 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'commentId': self._serialize.url("comment_id", comment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + comment_id=comment_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 d217cf31e9d8b..b2453f81c6002 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -74,7 +80,8 @@ def list_by_service( :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[~azure.mgmt.apimanagement.models.IssueCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCollection"] @@ -82,45 +89,43 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand_comments_attachments is not None: - query_parameters['expandCommentsAttachments'] = self._serialize.query("expand_comments_attachments", expand_comments_attachments, 'bool') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IssueCollection', pipeline_response) + deserialized = self._deserialize("IssueCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -133,17 +138,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -173,46 +180,39 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -245,49 +245,42 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand_comments_attachments is not None: - query_parameters['expandCommentsAttachments'] = self._serialize.query("expand_comments_attachments", expand_comments_attachments, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + expand_comments_attachments=expand_comments_attachments, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -324,59 +317,53 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'IssueContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'IssueContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -413,53 +400,47 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'IssueUpdateContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'IssueUpdateContract') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -493,39 +474,30 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 new file mode 100644 index 0000000000000..e7b53e97e7d5f --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_client_operations.py @@ -0,0 +1,148 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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 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.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') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApiManagementClientOperationsMixin: + + async def _perform_connectivity_check_async_initial( + self, + resource_group_name: str, + service_name: str, + connectivity_check_request_params: "_models.ConnectivityCheckRequest", + **kwargs: Any + ) -> Optional["_models.ConnectivityCheckResponse"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ConnectivityCheckResponse"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(connectivity_check_request_params, 'ConnectivityCheckRequest') + + request = build_perform_connectivity_check_async_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._perform_connectivity_check_async_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + + deserialized = None + if response.status_code == 200: + 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 + + + @distributed_trace_async + async def begin_perform_connectivity_check_async( + self, + resource_group_name: str, + service_name: str, + connectivity_check_request_params: "_models.ConnectivityCheckRequest", + **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. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param connectivity_check_request_params: Connectivity Check request parameters. + :type connectivity_check_request_params: + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequest + :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 + """ + 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] + if cont_token is None: + raw_result = await self._perform_connectivity_check_async_initial( + resource_group_name=resource_group_name, + service_name=service_name, + connectivity_check_request_params=connectivity_check_request_params, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_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 cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + 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 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 bc927cf54fd79..9faf7e893832a 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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[~azure.mgmt.apimanagement.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_operations.py index 1792c41673d53..80883aa9d9b98 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 @@ -5,19 +5,24 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,39 +60,28 @@ async def _restore_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._restore_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') + + request = build_restore_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._restore_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -97,8 +91,11 @@ async def _restore_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _restore_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore'} # type: ignore + + @distributed_trace_async async def begin_restore( self, resource_group_name: str, @@ -119,15 +116,20 @@ async def begin_restore( :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters :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. + :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: + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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', @@ -139,27 +141,21 @@ async def begin_restore( resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -171,6 +167,7 @@ def get_long_running_output(pipeline_response): ) else: 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 async def _backup_initial( @@ -185,39 +182,28 @@ async def _backup_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._backup_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_backup_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._backup_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -227,8 +213,11 @@ async def _backup_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _backup_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup'} # type: ignore + + @distributed_trace_async async def begin_backup( self, resource_group_name: str, @@ -247,15 +236,20 @@ async def begin_backup( :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters :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. + :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: + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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', @@ -267,27 +261,21 @@ async def begin_backup( resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -299,6 +287,7 @@ def get_long_running_output(pipeline_response): ) else: 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 async def _create_or_update_initial( @@ -313,39 +302,28 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ApiManagementServiceResource') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiManagementServiceResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -358,8 +336,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -378,15 +359,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource :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. + :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: + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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', @@ -398,27 +384,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -430,6 +410,7 @@ def get_long_running_output(pipeline_response): ) else: 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 async def _update_initial( @@ -444,39 +425,28 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ApiManagementServiceUpdateParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiManagementServiceUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -486,8 +456,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -505,15 +478,20 @@ async def begin_update( :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceUpdateParameters :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. + :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: + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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', @@ -525,27 +503,21 @@ async def begin_update( resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -557,8 +529,10 @@ def get_long_running_output(pipeline_response): ) else: 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 + @distributed_trace_async async def get( self, resource_group_name: str, @@ -581,33 +555,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) @@ -616,8 +580,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -629,34 +595,23 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 202: @@ -666,8 +621,11 @@ async def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _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, @@ -682,15 +640,19 @@ async def begin_delete( :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. - :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. + :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 None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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', @@ -704,24 +666,17 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -733,8 +688,10 @@ def get_long_running_output(pipeline_response): ) else: 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 + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -745,8 +702,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. :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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceListResult] + :return: An iterator like instance of either ApiManagementServiceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceListResult"] @@ -754,35 +713,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApiManagementServiceListResult', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -795,17 +750,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service'} # type: ignore + @distributed_trace def list( self, **kwargs: Any @@ -813,8 +770,10 @@ def list( """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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceListResult] + :return: An iterator like instance of either ApiManagementServiceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceListResult"] @@ -822,34 +781,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApiManagementServiceListResult', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -862,17 +816,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service'} # type: ignore + @distributed_trace_async async def get_sso_token( self, resource_group_name: str, @@ -895,33 +851,23 @@ async def get_sso_token( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_sso_token.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApiManagementServiceGetSsoTokenResult', pipeline_response) @@ -930,8 +876,11 @@ async def get_sso_token( return cls(pipeline_response, deserialized, {}) return deserialized + get_sso_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken'} # type: ignore + + @distributed_trace_async async def check_name_availability( self, parameters: "_models.ApiManagementServiceCheckNameAvailabilityParameters", @@ -940,7 +889,8 @@ async def check_name_availability( """Checks availability and correctness of a name for an API Management service. :param parameters: Parameters supplied to the CheckNameAvailability operation. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceCheckNameAvailabilityParameters + :type parameters: + ~azure.mgmt.apimanagement.models.ApiManagementServiceCheckNameAvailabilityParameters :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 @@ -951,36 +901,26 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ApiManagementServiceCheckNameAvailabilityParameters') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiManagementServiceCheckNameAvailabilityParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApiManagementServiceNameAvailabilityResult', pipeline_response) @@ -989,8 +929,11 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + 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 @@ -1007,31 +950,21 @@ async def get_domain_ownership_identifier( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - # Construct URL - url = self.get_domain_ownership_identifier.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_domain_ownership_identifier_request( + subscription_id=self._config.subscription_id, + template_url=self.get_domain_ownership_identifier.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApiManagementServiceGetDomainOwnershipIdentifierResult', pipeline_response) @@ -1040,8 +973,10 @@ async def get_domain_ownership_identifier( return cls(pipeline_response, deserialized, {}) return deserialized + 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, @@ -1054,42 +989,31 @@ async def _apply_network_configuration_updates_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._apply_network_configuration_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'ApiManagementServiceApplyNetworkConfigurationParameters') + _json = self._serialize.body(parameters, 'ApiManagementServiceApplyNetworkConfigurationParameters') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_apply_network_configuration_updates_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._apply_network_configuration_updates_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -1099,8 +1023,11 @@ async def _apply_network_configuration_updates_initial( 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 + + @distributed_trace_async async def begin_apply_network_configuration_updates( self, resource_group_name: str, @@ -1118,18 +1045,24 @@ async def begin_apply_network_configuration_updates( :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. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceApplyNetworkConfigurationParameters + :type parameters: + ~azure.mgmt.apimanagement.models.ApiManagementServiceApplyNetworkConfigurationParameters :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. + :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: + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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', @@ -1141,27 +1074,21 @@ async def begin_apply_network_configuration_updates( resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -1173,4 +1100,5 @@ def get_long_running_output(pipeline_response): ) else: 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 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 03975ed40cc85..beef8124fdd4e 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_available_service_skus( self, resource_group_name: str, @@ -57,7 +63,8 @@ def list_available_service_skus( :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.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ResourceSkuResults] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ResourceSkuResults] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuResults"] @@ -65,36 +72,33 @@ def list_available_service_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_available_service_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ResourceSkuResults', pipeline_response) + deserialized = self._deserialize("ResourceSkuResults", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -107,12 +111,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_skus_operations.py index ab2509d59ff65..f0aedabd075e4 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -48,8 +54,10 @@ def list( """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.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementSkusResult] + :return: An iterator like instance of either ApiManagementSkusResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementSkusResult"] @@ -57,34 +65,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApiManagementSkusResult', pipeline_response) + deserialized = self._deserialize("ApiManagementSkusResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,12 +100,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_operations.py index 8aaa20a8a1f60..8c02024349ef6 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_api( self, resource_group_name: str, @@ -78,7 +84,8 @@ def list_by_api( :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.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.OperationCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.OperationCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationCollection"] @@ -86,45 +93,43 @@ def list_by_api( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_api.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_api.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationCollection', pipeline_response) + deserialized = self._deserialize("OperationCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -137,17 +142,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -178,46 +185,39 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -248,47 +248,41 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OperationContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -326,59 +320,53 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'OperationContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'OperationContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -416,53 +404,47 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'OperationUpdateContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'OperationUpdateContract') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OperationContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -497,39 +479,30 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 fb2c7d9fd81ba..81fa5c2f9fbca 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 @@ -5,16 +5,20 @@ # 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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_operation( self, resource_group_name: str, @@ -70,35 +75,25 @@ async def list_by_operation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_operation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyCollection', pipeline_response) @@ -107,8 +102,11 @@ async def list_by_operation( 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 + + @distributed_trace_async async def get_entity_tag( self, resource_group_name: str, @@ -142,47 +140,40 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + template_url=self.get_entity_tag.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -219,50 +210,43 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if format is not None: - query_parameters['format'] = self._serialize.query("format", format, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -303,60 +287,54 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -394,40 +372,31 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 fe463e1add600..e6614d7ab4b6f 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 @@ -5,19 +5,24 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -87,46 +93,43 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, 'str') - if expand_api_version_set is not None: - query_parameters['expandApiVersionSet'] = self._serialize.query("expand_api_version_set", expand_api_version_set, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApiCollection', pipeline_response) + deserialized = self._deserialize("ApiCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -139,17 +142,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -176,45 +181,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -241,51 +239,39 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json, application/vnd.swagger.doc+json, application/vnd.oai.openapi+json, application/vnd.sun.wadl+xml, application/wsdl+xml" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 200]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - deserialized = self._deserialize('ApiContract', pipeline_response) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - if response.status_code == 200: - 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 + async def _create_or_update_initial( self, resource_group_name: str, @@ -300,59 +286,52 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiCreateOrUpdateParameter') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ApiCreateOrUpdateParameter') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiContract', pipeline_response) if response.status_code == 201: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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 + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -378,15 +357,19 @@ async def begin_create_or_update( :type if_match: 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. + :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) + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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', @@ -400,31 +383,24 @@ async def begin_create_or_update( api_id=api_id, parameters=parameters, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', 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) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -436,8 +412,10 @@ def get_long_running_output(pipeline_response): ) else: 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 + @distributed_trace_async async def update( self, resource_group_name: str, @@ -471,52 +449,46 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiUpdateContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -550,37 +522,26 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if delete_revisions is not None: - query_parameters['deleteRevisions'] = self._serialize.query("delete_revisions", delete_revisions, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + delete_revisions=delete_revisions, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -588,6 +549,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + + @distributed_trace def list_by_tags( self, resource_group_name: str, @@ -621,8 +584,10 @@ def list_by_tags( :param include_not_tagged_apis: Include not tagged APIs. :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.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] + :return: An iterator like instance of either TagResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] @@ -630,44 +595,41 @@ def list_by_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if include_not_tagged_apis is not None: - query_parameters['includeNotTaggedApis'] = self._serialize.query("include_not_tagged_apis", include_not_tagged_apis, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagResourceCollection', pipeline_response) + deserialized = self._deserialize("TagResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -680,12 +642,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_policy_operations.py index f6f1273fc02eb..6160e8cfd301b 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 @@ -5,16 +5,20 @@ # 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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_api( self, resource_group_name: str, @@ -66,34 +71,24 @@ async def list_by_api( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_api.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyCollection', pipeline_response) @@ -102,8 +97,11 @@ async def list_by_api( 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 + + @distributed_trace_async async def get_entity_tag( self, resource_group_name: str, @@ -133,46 +131,39 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -205,54 +196,48 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json, application/vnd.ms-azure-apim.policy+xml, application/vnd.ms-azure-apim.policy.raw+xml" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if format is not None: - query_parameters['format'] = self._serialize.query("format", format, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -289,59 +274,53 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -375,39 +354,30 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 25e68904c8b70..0397acd9cf3cf 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_apis( self, resource_group_name: str, @@ -69,7 +75,8 @@ def list_by_apis( :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.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductCollection"] @@ -77,43 +84,41 @@ def list_by_apis( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_apis.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_apis.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductCollection', pipeline_response) + deserialized = self._deserialize("ProductCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -126,12 +131,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_release_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_release_operations.py index db09304b22f9e..d09ddff0db11c 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -70,8 +76,10 @@ def list_by_service( :param skip: Number of records to skip. :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.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiReleaseCollection] + :return: An iterator like instance of either ApiReleaseCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiReleaseCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiReleaseCollection"] @@ -79,43 +87,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApiReleaseCollection', pipeline_response) + deserialized = self._deserialize("ApiReleaseCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -128,17 +134,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -168,46 +176,39 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -237,47 +238,41 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiReleaseContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -314,59 +309,53 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiReleaseContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ApiReleaseContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -403,53 +392,47 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiReleaseContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ApiReleaseContract') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiReleaseContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -483,39 +466,30 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 ab1dd235dd5ec..e734599a1e054 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -68,8 +74,10 @@ def list_by_service( :param skip: Number of records to skip. :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.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiRevisionCollection] + :return: An iterator like instance of either ApiRevisionCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiRevisionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiRevisionCollection"] @@ -77,43 +85,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApiRevisionCollection', pipeline_response) + deserialized = self._deserialize("ApiRevisionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -126,12 +132,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_schema_operations.py index 5eb0cf2e5e321..e4b46d1c9af1d 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 @@ -5,19 +5,24 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_api( self, resource_group_name: str, @@ -72,7 +78,8 @@ def list_by_api( :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[~azure.mgmt.apimanagement.models.SchemaCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SchemaCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SchemaCollection"] @@ -80,43 +87,41 @@ def list_by_api( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_api.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_api.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SchemaCollection', pipeline_response) + deserialized = self._deserialize("SchemaCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -129,17 +134,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -157,8 +164,8 @@ async def get_entity_tag( :param api_id: API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param schema_id: Schema identifier within an API. Must be unique in the current API Management - service instance. + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. :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) @@ -170,46 +177,39 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'schemaId': self._serialize.url("schema_id", schema_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -227,8 +227,8 @@ async def get( :param api_id: API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param schema_id: Schema identifier within an API. Must be unique in the current API Management - service instance. + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. :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) @@ -240,47 +240,40 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'schemaId': self._serialize.url("schema_id", schema_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SchemaContract', pipeline_response) 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 + async def _create_or_update_initial( self, resource_group_name: str, @@ -296,60 +289,53 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'schemaId': self._serialize.url("schema_id", schema_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SchemaContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SchemaContract') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SchemaContract', pipeline_response) if response.status_code == 201: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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 + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -369,8 +355,8 @@ async def begin_create_or_update( :param api_id: API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param schema_id: Schema identifier within an API. Must be unique in the current API Management - service instance. + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. :type schema_id: str :param parameters: The schema contents to apply. :type parameters: ~azure.mgmt.apimanagement.models.SchemaContract @@ -379,15 +365,19 @@ async def begin_create_or_update( :type if_match: 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. + :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) + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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', @@ -402,32 +392,24 @@ async def begin_create_or_update( schema_id=schema_id, parameters=parameters, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', 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) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'schemaId': self._serialize.url("schema_id", schema_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -439,8 +421,10 @@ def get_long_running_output(pipeline_response): ) else: 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 + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -460,8 +444,8 @@ async def delete( :param api_id: API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param schema_id: Schema identifier within an API. Must be unique in the current API Management - service instance. + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. :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. @@ -478,41 +462,31 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'schemaId': self._serialize.url("schema_id", schema_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + force=force, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 bbaa7ba31a965..8f0c621771ec3 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -71,8 +77,10 @@ def list_by_service( :param skip: Number of records to skip. :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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagDescriptionCollection] + :return: An iterator like instance of either TagDescriptionCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagDescriptionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDescriptionCollection"] @@ -80,43 +88,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagDescriptionCollection', pipeline_response) + deserialized = self._deserialize("TagDescriptionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -129,17 +135,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -170,46 +178,39 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'tagDescriptionId': self._serialize.url("tag_description_id", tag_description_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -240,47 +241,41 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'tagDescriptionId': self._serialize.url("tag_description_id", tag_description_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagDescriptionContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -318,59 +313,53 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'tagDescriptionId': self._serialize.url("tag_description_id", tag_description_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagDescriptionCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagDescriptionCreateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_description_id=tag_description_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -405,39 +394,30 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'tagDescriptionId': self._serialize.url("tag_description_id", tag_description_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_description_id=tag_description_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 0c9fc79b133da..97a114daa565e 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -64,8 +70,10 @@ def list_by_service( :param skip: Number of records to skip. :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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiVersionSetCollection] + :return: An iterator like instance of either ApiVersionSetCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiVersionSetCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiVersionSetCollection"] @@ -73,42 +81,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApiVersionSetCollection', pipeline_response) + deserialized = self._deserialize("ApiVersionSetCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -121,17 +126,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -158,45 +165,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -223,46 +223,40 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -296,58 +290,52 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiVersionSetContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ApiVersionSetContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -381,52 +369,46 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiVersionSetUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -457,38 +439,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 bffd441282434..08417c214513f 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -67,8 +73,10 @@ def list_by_service( :param skip: Number of records to skip. :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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AuthorizationServerCollection] + :return: An iterator like instance of either AuthorizationServerCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AuthorizationServerCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerCollection"] @@ -76,42 +84,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AuthorizationServerCollection', pipeline_response) + deserialized = self._deserialize("AuthorizationServerCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -124,17 +129,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -160,45 +167,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -224,46 +224,40 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -296,58 +290,52 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AuthorizationServerContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AuthorizationServerContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authsid=authsid, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -380,52 +368,46 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AuthorizationServerUpdateContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AuthorizationServerUpdateContract') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authsid=authsid, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -455,35 +437,25 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -491,6 +463,8 @@ async def delete( 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, @@ -516,42 +490,35 @@ async def list_secrets( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_secrets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AuthorizationServerSecretsContract', pipeline_response) 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 + 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 e3170f9bab854..18c34a2f56b8d 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -68,7 +74,8 @@ def list_by_service( :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.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.BackendCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.BackendCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BackendCollection"] @@ -76,42 +83,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BackendCollection', pipeline_response) + deserialized = self._deserialize("BackendCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -124,17 +128,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -161,45 +167,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -226,46 +225,40 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('BackendContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -299,58 +292,52 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BackendContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'BackendContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -384,52 +371,46 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BackendUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('BackendContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -460,35 +441,25 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -496,6 +467,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + + @distributed_trace_async async def reconnect( self, resource_group_name: str, @@ -526,45 +499,36 @@ async def reconnect( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.reconnect.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'BackendReconnectContract') + _json = self._serialize.body(parameters, 'BackendReconnectContract') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _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, + content_type=content_type, + json=_json, + template_url=self.reconnect.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) 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 0ea85ee83ff19..900208a7e0b7a 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -61,7 +67,8 @@ def list_by_service( :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[~azure.mgmt.apimanagement.models.CacheCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.CacheCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.CacheCollection"] @@ -69,40 +76,37 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('CacheCollection', pipeline_response) + deserialized = self._deserialize("CacheCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,17 +119,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -152,45 +158,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -217,46 +216,40 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CacheContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -290,58 +283,52 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CacheContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CacheContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + cache_id=cache_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -375,52 +362,46 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CacheUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CacheContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -451,38 +432,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 0e72299cfb57a..40ad3c6727f76 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -72,8 +78,10 @@ def list_by_service( entities which failed refresh. :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.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.CertificateCollection] + :return: An iterator like instance of either CertificateCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.CertificateCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateCollection"] @@ -81,44 +89,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if is_key_vault_refresh_failed is not None: - query_parameters['isKeyVaultRefreshFailed'] = self._serialize.query("is_key_vault_refresh_failed", is_key_vault_refresh_failed, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('CertificateCollection', pipeline_response) + deserialized = self._deserialize("CertificateCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -131,17 +136,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -168,45 +175,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -233,46 +233,40 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CertificateContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -306,58 +300,52 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CertificateCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -388,35 +376,25 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -424,6 +402,8 @@ async def delete( 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, @@ -450,42 +430,35 @@ async def refresh_secret( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.refresh_secret.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CertificateContract', pipeline_response) 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 + 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 1cd3e0bdd2408..c6f07b4f451bb 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -57,8 +63,10 @@ def list_by_service( :param content_type_id: Content type identifier. :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.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ContentItemCollection] + :return: An iterator like instance of either ContentItemCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ContentItemCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentItemCollection"] @@ -66,37 +74,35 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ContentItemCollection', pipeline_response) + deserialized = self._deserialize("ContentItemCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,17 +115,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -149,46 +157,39 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), - 'contentItemId': self._serialize.url("content_item_id", content_item_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -217,47 +218,41 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), - 'contentItemId': self._serialize.url("content_item_id", content_item_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ContentItemContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -290,54 +285,48 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), - 'contentItemId': self._serialize.url("content_item_id", content_item_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + content_item_id=content_item_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -370,39 +359,30 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), - 'contentItemId': self._serialize.url("content_item_id", content_item_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + content_item_id=content_item_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 489858dc5724b..b9d3113963f6b 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -55,8 +61,10 @@ def list_by_service( :param service_name: The name of the API Management service. :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.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ContentTypeCollection] + :return: An iterator like instance of either ContentTypeCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ContentTypeCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentTypeCollection"] @@ -64,36 +72,33 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ContentTypeCollection', pipeline_response) + deserialized = self._deserialize("ContentTypeCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,17 +111,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -143,46 +150,40 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ContentTypeContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -214,53 +215,47 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -292,38 +287,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 7d2ec7af5aba6..ebd0706890a78 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 @@ -5,16 +5,20 @@ # 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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_entity_tag( self, resource_group_name: str, @@ -62,44 +67,37 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -122,45 +120,39 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PortalDelegationSettings', pipeline_response) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -190,39 +182,29 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PortalDelegationSettings') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PortalDelegationSettings') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -230,6 +212,8 @@ async def update( update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -259,40 +243,29 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PortalDelegationSettings') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PortalDelegationSettings') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PortalDelegationSettings', pipeline_response) @@ -301,8 +274,11 @@ async def create_or_update( 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 + + @distributed_trace_async async def list_secrets( self, resource_group_name: str, @@ -325,33 +301,23 @@ async def list_secrets( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_secrets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PortalSettingValidationKeyContract', pipeline_response) @@ -360,4 +326,6 @@ async def list_secrets( 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 + 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 a9ccead25a571..8081e86f3d1b6 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 @@ -5,19 +5,24 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -50,8 +56,10 @@ def list_by_subscription( """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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DeletedServicesCollection] + :return: An iterator like instance of either DeletedServicesCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DeletedServicesCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedServicesCollection"] @@ -59,34 +67,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DeletedServicesCollection', pipeline_response) + deserialized = self._deserialize("DeletedServicesCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -99,17 +102,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -132,33 +137,23 @@ async def get_by_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_by_name.metadata['url'] # type: ignore - path_format_arguments = { - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'location': self._serialize.url("location", location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DeletedServiceContract', pipeline_response) @@ -167,8 +162,10 @@ async def get_by_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}'} # type: ignore + async def _purge_initial( self, service_name: str, @@ -180,34 +177,23 @@ async def _purge_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._purge_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'location': self._serialize.url("location", location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_purge_request_initial( + service_name=service_name, + subscription_id=self._config.subscription_id, + location=location, + template_url=self._purge_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 202: @@ -217,8 +203,11 @@ async def _purge_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _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, @@ -233,15 +222,19 @@ async def begin_purge( :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. - :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. + :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 None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :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 DeletedServiceContract or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.DeletedServiceContract] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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', @@ -255,24 +248,17 @@ async def begin_purge( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeletedServiceContract', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'location': self._serialize.url("location", location, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -284,4 +270,5 @@ def get_long_running_output(pipeline_response): ) else: 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 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 bdbf1567516e6..566f2fdea699e 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -65,8 +71,10 @@ def list_by_service( :param skip: Number of records to skip. :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.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DiagnosticCollection] + :return: An iterator like instance of either DiagnosticCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DiagnosticCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticCollection"] @@ -74,42 +82,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DiagnosticCollection', pipeline_response) + deserialized = self._deserialize("DiagnosticCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -122,17 +127,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -159,45 +166,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -224,46 +224,40 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -297,58 +291,52 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DiagnosticContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DiagnosticContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -382,52 +370,46 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DiagnosticContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DiagnosticContract') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -458,38 +440,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 2fb72c13e9ac6..6a6984be143a6 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -65,8 +71,10 @@ def list_by_service( :param skip: Number of records to skip. :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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.EmailTemplateCollection] + :return: An iterator like instance of either EmailTemplateCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.EmailTemplateCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EmailTemplateCollection"] @@ -74,42 +82,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EmailTemplateCollection', pipeline_response) + deserialized = self._deserialize("EmailTemplateCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -122,17 +127,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -158,45 +165,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("template_name", template_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -222,46 +222,40 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("template_name", template_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('EmailTemplateContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -294,41 +288,30 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("template_name", template_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'EmailTemplateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -341,8 +324,11 @@ async def create_or_update( 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -375,52 +361,46 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("template_name", template_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'EmailTemplateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('EmailTemplateContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -450,38 +430,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("template_name", template_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 9e4f374f6c4bd..052e7ad2f9d74 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -78,43 +84,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApiCollection', pipeline_response) + deserialized = self._deserialize("ApiCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -127,17 +131,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -167,46 +173,39 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -239,43 +238,33 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'AssociationContract') + _json = self._serialize.body(parameters, 'AssociationContract') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -288,8 +277,11 @@ async def create_or_update( 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -319,38 +311,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 4d2be3a9b8bff..f789a2216314e 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -69,8 +75,10 @@ def list_by_service( :param skip: Number of records to skip. :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) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityCollection] + :return: An iterator like instance of either GatewayCertificateAuthorityCollection or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCertificateAuthorityCollection"] @@ -78,43 +86,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('GatewayCertificateAuthorityCollection', pipeline_response) + deserialized = self._deserialize("GatewayCertificateAuthorityCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -127,17 +133,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -168,46 +176,39 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'certificateId': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -238,47 +239,41 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'certificateId': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayCertificateAuthorityContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -316,59 +311,53 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'certificateId': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GatewayCertificateAuthorityContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GatewayCertificateAuthorityContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -403,39 +392,30 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'certificateId': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 4b4eb4c9325dd..2afe3a60e9bb9 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -70,8 +76,10 @@ def list_by_service( :param skip: Number of records to skip. :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) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationCollection] + :return: An iterator like instance of either GatewayHostnameConfigurationCollection or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayHostnameConfigurationCollection"] @@ -79,43 +87,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('GatewayHostnameConfigurationCollection', pipeline_response) + deserialized = self._deserialize("GatewayHostnameConfigurationCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -128,17 +134,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -170,46 +178,39 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'hcId': self._serialize.url("hc_id", hc_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -240,47 +241,41 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'hcId': self._serialize.url("hc_id", hc_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayHostnameConfigurationContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -318,59 +313,53 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'hcId': self._serialize.url("hc_id", hc_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GatewayHostnameConfigurationContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GatewayHostnameConfigurationContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + hc_id=hc_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -405,39 +394,30 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'hcId': self._serialize.url("hc_id", hc_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + hc_id=hc_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 87c011a33c584..2c7388ca236e3 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -69,7 +75,8 @@ def list_by_service( :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.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCollection"] @@ -77,42 +84,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('GatewayCollection', pipeline_response) + deserialized = self._deserialize("GatewayCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,17 +129,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -162,45 +168,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -227,46 +226,40 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -300,58 +293,52 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GatewayContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GatewayContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -385,52 +372,46 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GatewayContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GatewayContract') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -461,35 +442,25 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -497,6 +468,8 @@ async def delete( 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, @@ -523,46 +496,40 @@ async def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayKeysContract', pipeline_response) 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 + + @distributed_trace_async async def regenerate_key( self, resource_group_name: str, @@ -592,39 +559,29 @@ async def regenerate_key( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GatewayKeyRegenerationRequestContract') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + 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, + content_type=content_type, + json=_json, + template_url=self.regenerate_key.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GatewayKeyRegenerationRequestContract') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -632,6 +589,8 @@ async def regenerate_key( regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/regenerateKey'} # type: ignore + + @distributed_trace_async async def generate_token( self, resource_group_name: str, @@ -661,39 +620,29 @@ async def generate_token( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.generate_token.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GatewayTokenRequestContract') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + 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, + content_type=content_type, + json=_json, + template_url=self.generate_token.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GatewayTokenRequestContract') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GatewayTokenContract', pipeline_response) @@ -702,4 +651,6 @@ async def generate_token( 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 + 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 new file mode 100644 index 0000000000000..27ec69135260c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_global_schema_operations.py @@ -0,0 +1,462 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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.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') +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable["_models.GlobalSchemaCollection"]: + """Lists a collection of schemas registered with service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :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 + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GlobalSchemaCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GlobalSchemaCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + template_url=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GlobalSchemaCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + 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: + """Gets the entity state (Etag) version of the Schema specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. + :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) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + + if cls: + return cls(pipeline_response, None, response_headers) + return 200 <= response.status_code <= 299 + + 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": + """Gets the details of the Schema specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. + :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: ~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 + } + error_map.update(kwargs.pop('error_map', {})) + + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('GlobalSchemaContract', pipeline_response) + + 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 + + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + schema_id: str, + parameters: "_models.GlobalSchemaContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.GlobalSchemaContract"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GlobalSchemaContract"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GlobalSchemaContract') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + + deserialized = None + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('GlobalSchemaContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + 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 + + + @distributed_trace_async + 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, + **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. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. + :type schema_id: str + :param parameters: Create or update parameters. + :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. + :type if_match: 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 + """ + 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] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + schema_id=schema_id, + parameters=parameters, + if_match=if_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + 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) + 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 cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + 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 + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + schema_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes specific Schema. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. + :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. + :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) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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 61e6e1186b02b..cab3019823930 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -69,7 +75,8 @@ def list_by_service( :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[~azure.mgmt.apimanagement.models.GroupCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GroupCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupCollection"] @@ -77,42 +84,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('GroupCollection', pipeline_response) + deserialized = self._deserialize("GroupCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,17 +129,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -162,45 +168,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -227,46 +226,40 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GroupContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -300,58 +293,52 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GroupCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -385,52 +372,46 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GroupUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GroupContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -461,38 +442,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 e6b9d2fe3f214..2275b467724c0 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -75,7 +81,8 @@ def list( :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[~azure.mgmt.apimanagement.models.UserCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.UserCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.UserCollection"] @@ -83,43 +90,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UserCollection', pipeline_response) + deserialized = self._deserialize("UserCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -132,17 +137,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -172,43 +179,35 @@ async def check_entity_exists( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.check_entity_exists.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: 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 + + @distributed_trace_async async def create( self, resource_group_name: str, @@ -238,35 +237,25 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -279,8 +268,11 @@ async def create( 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -310,38 +302,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 9c83ceff4de9d..9f8ae40145965 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -54,8 +60,10 @@ def list_by_service( :param service_name: The name of the API Management service. :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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IdentityProviderList] + :return: An iterator like instance of either IdentityProviderList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IdentityProviderList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IdentityProviderList"] @@ -63,36 +71,33 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IdentityProviderList', pipeline_response) + deserialized = self._deserialize("IdentityProviderList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,17 +110,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -141,45 +148,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -206,46 +206,40 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IdentityProviderContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -278,58 +272,52 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'IdentityProviderCreateContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'IdentityProviderCreateContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + identity_provider_name=identity_provider_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -362,52 +350,46 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'IdentityProviderUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IdentityProviderContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -437,35 +419,25 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -473,6 +445,8 @@ async def delete( 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, @@ -498,42 +472,35 @@ async def list_secrets( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_secrets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ClientSecretContract', pipeline_response) 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 + 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 9754af78925d6..0efd7dc398ff2 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -71,7 +77,8 @@ def list_by_service( :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[~azure.mgmt.apimanagement.models.IssueCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCollection"] @@ -79,42 +86,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IssueCollection', pipeline_response) + deserialized = self._deserialize("IssueCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -127,17 +131,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -164,42 +170,35 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueContract', pipeline_response) 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 + 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 f9870d6498781..cfa6293fa75cd 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -69,7 +75,8 @@ def list_by_service( :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[~azure.mgmt.apimanagement.models.LoggerCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.LoggerCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LoggerCollection"] @@ -77,42 +84,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('LoggerCollection', pipeline_response) + deserialized = self._deserialize("LoggerCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,17 +129,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -161,45 +167,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -225,46 +224,40 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('LoggerContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -297,58 +290,52 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'LoggerContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'LoggerContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -381,52 +368,46 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'LoggerUpdateContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('LoggerContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -456,38 +437,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 7365d146c5497..67c35065f8ca5 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 @@ -5,19 +5,24 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -73,8 +79,10 @@ def list_by_service( entities which failed refresh. :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.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.NamedValueCollection] + :return: An iterator like instance of either NamedValueCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.NamedValueCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueCollection"] @@ -82,44 +90,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if is_key_vault_refresh_failed is not None: - query_parameters['isKeyVaultRefreshFailed'] = self._serialize.query("is_key_vault_refresh_failed", is_key_vault_refresh_failed, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NamedValueCollection', pipeline_response) + deserialized = self._deserialize("NamedValueCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -132,17 +137,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -168,45 +175,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -232,46 +232,39 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) 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 + async def _create_or_update_initial( self, resource_group_name: str, @@ -286,59 +279,52 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'NamedValueCreateContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'NamedValueCreateContract') + + request = build_create_or_update_request_initial( + 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, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) if response.status_code == 201: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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 + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -363,15 +349,19 @@ async def begin_create_or_update( :type if_match: 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. + :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) + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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', @@ -385,31 +375,24 @@ async def begin_create_or_update( named_value_id=named_value_id, parameters=parameters, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', 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) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -421,6 +404,7 @@ def get_long_running_output(pipeline_response): ) else: 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 async def _update_initial( @@ -437,54 +421,47 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'NamedValueUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'NamedValueUpdateParameters') + + request = build_update_request_initial( + 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, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) if 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 + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -509,15 +486,19 @@ async def begin_update( :type parameters: ~azure.mgmt.apimanagement.models.NamedValueUpdateParameters :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. + :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) + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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', @@ -531,31 +512,24 @@ async def begin_update( named_value_id=named_value_id, if_match=if_match, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', 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) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -567,8 +541,10 @@ def get_long_running_output(pipeline_response): ) else: 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 + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -598,35 +574,25 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -634,6 +600,8 @@ async def delete( 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, @@ -659,46 +627,39 @@ async def list_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_value.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueSecretContract', pipeline_response) 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 + async def _refresh_secret_initial( self, resource_group_name: str, @@ -711,48 +672,41 @@ async def _refresh_secret_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._refresh_secret_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_refresh_secret_request_initial( + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) if 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 + + @distributed_trace_async async def begin_refresh_secret( self, resource_group_name: str, @@ -770,15 +724,18 @@ async def begin_refresh_secret( :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. - :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. + :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) + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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', @@ -793,28 +750,20 @@ async def begin_refresh_secret( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', 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) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -826,4 +775,5 @@ def get_long_running_output(pipeline_response): ) else: 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 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 245150098aae8..c0f7e75078c2b 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 @@ -5,16 +5,20 @@ # 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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_service( self, resource_group_name: str, @@ -64,33 +69,23 @@ async def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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 = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('[NetworkStatusContractByLocation]', pipeline_response) @@ -99,8 +94,11 @@ async def list_by_service( return cls(pipeline_response, deserialized, {}) return deserialized + 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, @@ -129,34 +127,24 @@ async def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("location_name", location_name, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkStatusContract', pipeline_response) @@ -165,4 +153,6 @@ async def list_by_location( 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 + 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 a38e1be901f86..1eda64f0f9426 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -60,8 +66,10 @@ def list_by_service( :param skip: Number of records to skip. :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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.NotificationCollection] + :return: An iterator like instance of either NotificationCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.NotificationCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.NotificationCollection"] @@ -69,40 +77,37 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NotificationCollection', pipeline_response) + deserialized = self._deserialize("NotificationCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,17 +120,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -151,34 +158,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NotificationContract', pipeline_response) @@ -187,8 +184,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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, @@ -218,36 +218,25 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NotificationContract', pipeline_response) @@ -256,4 +245,6 @@ async def create_or_update( 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 + 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 21634bdac4c8e..adf2eb93552e2 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 @@ -5,16 +5,20 @@ # 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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_notification( self, resource_group_name: str, @@ -65,34 +70,24 @@ async def list_by_notification( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_notification.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RecipientEmailCollection', pipeline_response) @@ -101,8 +96,11 @@ async def list_by_notification( 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 + + @distributed_trace_async async def check_entity_exists( self, resource_group_name: str, @@ -131,43 +129,35 @@ async def check_entity_exists( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.check_entity_exists.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'email': self._serialize.url("email", email, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -196,35 +186,25 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'email': self._serialize.url("email", email, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -237,8 +217,11 @@ async def create_or_update( 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -267,38 +250,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'email': self._serialize.url("email", email, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 e96f821a917d7..30c73e2f08ab5 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 @@ -5,16 +5,20 @@ # 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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_notification( self, resource_group_name: str, @@ -65,34 +70,24 @@ async def list_by_notification( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_notification.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RecipientUserCollection', pipeline_response) @@ -101,8 +96,11 @@ async def list_by_notification( 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 + + @distributed_trace_async async def check_entity_exists( self, resource_group_name: str, @@ -131,43 +129,35 @@ async def check_entity_exists( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.check_entity_exists.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -196,35 +186,25 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -237,8 +217,11 @@ async def create_or_update( 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -267,38 +250,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 81a0ef02b5ead..dd28feaba17f2 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -67,8 +73,10 @@ def list_by_service( :param skip: Number of records to skip. :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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.OpenIdConnectProviderCollection] + :return: An iterator like instance of either OpenIdConnectProviderCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.OpenIdConnectProviderCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenIdConnectProviderCollection"] @@ -76,42 +84,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OpenIdConnectProviderCollection', pipeline_response) + deserialized = self._deserialize("OpenIdConnectProviderCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -124,17 +129,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -160,45 +167,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -224,46 +224,40 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -296,58 +290,52 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'OpenidConnectProviderContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'OpenidConnectProviderContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + opid=opid, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -380,52 +368,46 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'OpenidConnectProviderUpdateContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -455,35 +437,25 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -491,6 +463,8 @@ async def delete( 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, @@ -516,42 +490,35 @@ async def list_secrets( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_secrets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ClientSecretContract', pipeline_response) 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 + 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 b3f3766527678..26b12a2d65430 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_tags( self, resource_group_name: str, @@ -78,8 +84,10 @@ def list_by_tags( :param include_not_tagged_operations: Include not tagged Operations. :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.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] + :return: An iterator like instance of either TagResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] @@ -87,45 +95,43 @@ def list_by_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if include_not_tagged_operations is not None: - query_parameters['includeNotTaggedOperations'] = self._serialize.query("include_not_tagged_operations", include_not_tagged_operations, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagResourceCollection', pipeline_response) + deserialized = self._deserialize("TagResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -138,12 +144,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_outbound_network_dependencies_endpoints_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_outbound_network_dependencies_endpoints_operations.py new file mode 100644 index 0000000000000..3bb77038b2582 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_outbound_network_dependencies_endpoints_operations.py @@ -0,0 +1,97 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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.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') +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def list_by_service( + self, + resource_group_name: str, + service_name: str, + **kwargs: Any + ) -> "_models.OutboundEnvironmentEndpointList": + """Gets the network endpoints of all outbound dependencies of a ApiManagement service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :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: ~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 + } + error_map.update(kwargs.pop('error_map', {})) + + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('OutboundEnvironmentEndpointList', pipeline_response) + + 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 + 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 94e7ca7a00103..8e386b38f38f9 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 @@ -5,16 +5,20 @@ # 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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_service( self, resource_group_name: str, @@ -65,35 +70,24 @@ async def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if scope is not None: - query_parameters['scope'] = self._serialize.query("scope", scope, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyDescriptionCollection', pipeline_response) @@ -102,4 +96,6 @@ async def list_by_service( return cls(pipeline_response, deserialized, {}) return deserialized + 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 ea83cf9702e6f..19d6970cc99d2 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 @@ -5,16 +5,20 @@ # 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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_service( self, resource_group_name: str, @@ -62,33 +67,23 @@ async def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyCollection', pipeline_response) @@ -97,8 +92,11 @@ async def list_by_service( return cls(pipeline_response, deserialized, {}) return deserialized + 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, @@ -125,45 +123,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -192,48 +183,41 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if format is not None: - query_parameters['format'] = self._serialize.query("format", format, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -266,58 +250,52 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -347,38 +325,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 215ae674077bc..2edb41dcf0248 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 @@ -5,19 +5,24 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -76,8 +82,10 @@ def list_by_service( :param skip: Number of records to skip. :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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PortalRevisionCollection] + :return: An iterator like instance of either PortalRevisionCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PortalRevisionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalRevisionCollection"] @@ -85,42 +93,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PortalRevisionCollection', pipeline_response) + deserialized = self._deserialize("PortalRevisionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -133,17 +138,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -170,45 +177,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("portal_revision_id", portal_revision_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -235,46 +235,39 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("portal_revision_id", portal_revision_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PortalRevisionContract', pipeline_response) 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 + async def _create_or_update_initial( self, resource_group_name: str, @@ -288,53 +281,46 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("portal_revision_id", portal_revision_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PortalRevisionContract') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + 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, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PortalRevisionContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} 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) 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 + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -357,15 +343,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract :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. + :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: + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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', @@ -378,31 +369,24 @@ async def begin_create_or_update( service_name=service_name, portal_revision_id=portal_revision_id, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', 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) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("portal_revision_id", portal_revision_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -414,6 +398,7 @@ def get_long_running_output(pipeline_response): ) else: 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 async def _update_initial( @@ -430,54 +415,47 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("portal_revision_id", portal_revision_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PortalRevisionContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PortalRevisionContract') + + request = build_update_request_initial( + 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, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PortalRevisionContract', pipeline_response) if 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 + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -503,15 +481,20 @@ async def begin_update( :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract :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. + :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: + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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', @@ -525,31 +508,24 @@ async def begin_update( portal_revision_id=portal_revision_id, if_match=if_match, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', 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) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("portal_revision_id", portal_revision_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -561,4 +537,5 @@ def get_long_running_output(pipeline_response): ) else: 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 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 e5ca4e2422b94..a7458f17cac54 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 @@ -5,16 +5,20 @@ # 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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_service( self, resource_group_name: str, @@ -62,33 +67,23 @@ async def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PortalSettingsCollection', pipeline_response) @@ -97,4 +92,6 @@ async def list_by_service( return cls(pipeline_response, deserialized, {}) return deserialized + 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 new file mode 100644 index 0000000000000..0473213ccdbd2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_private_endpoint_connection_operations.py @@ -0,0 +1,517 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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.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') +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + """Lists all private endpoint connections of the API Management service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :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) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PrivateEndpointConnectionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + 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": + """Gets the details of the Private Endpoint Connection specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param private_endpoint_connection_name: Name of the private endpoint connection. + :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: ~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 + } + error_map.update(kwargs.pop('error_map', {})) + + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + + 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 + + + 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", + **kwargs: Any + ) -> Optional["_models.PrivateEndpointConnection"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(private_endpoint_connection_request, 'PrivateEndpointConnectionRequest') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + 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 + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection_request: "_models.PrivateEndpointConnectionRequest", + **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. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param private_endpoint_connection_name: Name of the private endpoint connection. + :type private_endpoint_connection_name: str + :param private_endpoint_connection_request: + :type private_endpoint_connection_request: + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequest + :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 + """ + 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] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection_request=private_endpoint_connection_request, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_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 cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + 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 + + async def _delete_initial( + 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 + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + + if cls: + return cls(pipeline_response, None, {}) + + _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 + ) -> AsyncLROPoller[None]: + """Deletes the specified Private Endpoint Connection. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param private_endpoint_connection_name: Name of the private endpoint connection. + :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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :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] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + service_name=service_name, + private_endpoint_connection_name=private_endpoint_connection_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + 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 cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + 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 + + @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. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :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: ~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 + } + error_map.update(kwargs.pop('error_map', {})) + + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + + 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 + + + @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. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param private_link_sub_resource_name: Name of the private link resource. + :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: ~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 + } + error_map.update(kwargs.pop('error_map', {})) + + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateLinkResource', pipeline_response) + + 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 + 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 16d30cae89420..e1a2e3dacbd67 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_product( self, resource_group_name: str, @@ -83,43 +89,41 @@ def list_by_product( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_product.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_product.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ApiCollection', pipeline_response) + deserialized = self._deserialize("ApiCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -132,17 +136,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -173,43 +179,35 @@ async def check_entity_exists( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.check_entity_exists.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -240,35 +238,25 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -281,8 +269,11 @@ async def create_or_update( 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -313,38 +304,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 b9ce5da9b8cdb..7d3acf225e83c 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_product( self, resource_group_name: str, @@ -71,7 +77,8 @@ def list_by_product( :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[~azure.mgmt.apimanagement.models.GroupCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GroupCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupCollection"] @@ -79,43 +86,41 @@ def list_by_product( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_product.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_product.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('GroupCollection', pipeline_response) + deserialized = self._deserialize("GroupCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -128,17 +133,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -169,43 +176,35 @@ async def check_entity_exists( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.check_entity_exists.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -236,35 +235,25 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -277,8 +266,11 @@ async def create_or_update( 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -309,38 +301,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 11743e2f40a98..2bf125cda427d 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -77,7 +83,8 @@ def list_by_service( :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.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductCollection"] @@ -85,46 +92,43 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if expand_groups is not None: - query_parameters['expandGroups'] = self._serialize.query("expand_groups", expand_groups, 'bool') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductCollection', pipeline_response) + deserialized = self._deserialize("ProductCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -137,17 +141,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -174,45 +180,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -239,46 +238,40 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ProductContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -312,58 +305,52 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ProductContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ProductContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -397,52 +384,46 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ProductUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ProductContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -476,37 +457,26 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if delete_subscriptions is not None: - query_parameters['deleteSubscriptions'] = self._serialize.query("delete_subscriptions", delete_subscriptions, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + delete_subscriptions=delete_subscriptions, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -514,6 +484,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + + @distributed_trace def list_by_tags( self, resource_group_name: str, @@ -545,8 +517,10 @@ def list_by_tags( :param include_not_tagged_products: Include not tagged Products. :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.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] + :return: An iterator like instance of either TagResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] @@ -554,44 +528,41 @@ def list_by_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if include_not_tagged_products is not None: - query_parameters['includeNotTaggedProducts'] = self._serialize.query("include_not_tagged_products", include_not_tagged_products, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagResourceCollection', pipeline_response) + deserialized = self._deserialize("TagResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -604,12 +575,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_policy_operations.py index e9f92acf8a8c9..974338a15313f 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 @@ -5,16 +5,20 @@ # 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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_product( self, resource_group_name: str, @@ -66,34 +71,24 @@ async def list_by_product( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_product.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyCollection', pipeline_response) @@ -102,8 +97,11 @@ async def list_by_product( 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 + + @distributed_trace_async async def get_entity_tag( self, resource_group_name: str, @@ -133,46 +131,39 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -205,49 +196,42 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if format is not None: - query_parameters['format'] = self._serialize.query("format", format, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -284,59 +268,53 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -370,39 +348,30 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 ff67f35c7b53e..c4a9c604ebbef 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -77,8 +83,10 @@ def list( :param skip: Number of records to skip. :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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionCollection] + :return: An iterator like instance of either SubscriptionCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionCollection"] @@ -86,43 +94,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionCollection', pipeline_response) + deserialized = self._deserialize("SubscriptionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -135,12 +141,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_counter_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_counter_keys_operations.py index e27f20796c98d..2f97a108c1fa4 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 @@ -5,16 +5,20 @@ # 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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_service( self, resource_group_name: str, @@ -69,34 +74,24 @@ async def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("quota_counter_key", quota_counter_key, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('QuotaCounterCollection', pipeline_response) @@ -105,8 +100,11 @@ async def list_by_service( 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -139,39 +137,29 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("quota_counter_key", quota_counter_key, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'QuotaCounterValueUpdateContract') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'QuotaCounterValueUpdateContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('QuotaCounterCollection', pipeline_response) @@ -180,4 +168,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + 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 1d3dfb32cb849..e936bc9eaa01e 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 @@ -5,16 +5,20 @@ # 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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -72,35 +77,25 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("quota_counter_key", quota_counter_key, 'str'), - 'quotaPeriodKey': self._serialize.url("quota_period_key", quota_period_key, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('QuotaCounterContract', pipeline_response) @@ -109,8 +104,11 @@ async def get( 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -145,40 +143,30 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("quota_counter_key", quota_counter_key, 'str'), - 'quotaPeriodKey': self._serialize.url("quota_period_key", quota_period_key, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'QuotaCounterValueUpdateContract') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + quota_counter_key=quota_counter_key, + quota_period_key=quota_period_key, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'QuotaCounterValueUpdateContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('QuotaCounterContract', pipeline_response) @@ -187,4 +175,6 @@ async def update( 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 + 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 3688a63570975..296fee724bf79 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -55,7 +61,8 @@ def list_by_service( :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[~azure.mgmt.apimanagement.models.RegionListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.RegionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RegionListResult"] @@ -63,36 +70,33 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RegionListResult', pipeline_response) + deserialized = self._deserialize("RegionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,12 +109,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_reports_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_reports_operations.py index 0b42603a81896..a847a551bacff 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 @@ -6,17 +6,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -42,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_api( self, resource_group_name: str, @@ -68,7 +74,8 @@ def list_by_api( :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[~azure.mgmt.apimanagement.models.ReportCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] @@ -76,43 +83,41 @@ def list_by_api( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_api.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_api.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ReportCollection', pipeline_response) + deserialized = self._deserialize("ReportCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,17 +130,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi'} # type: ignore + @distributed_trace def list_by_user( self, resource_group_name: str, @@ -174,7 +181,8 @@ def list_by_user( :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[~azure.mgmt.apimanagement.models.ReportCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] @@ -182,43 +190,41 @@ def list_by_user( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_user.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_user.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ReportCollection', pipeline_response) + deserialized = self._deserialize("ReportCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -231,17 +237,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_user.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser'} # type: ignore + @distributed_trace def list_by_operation( self, resource_group_name: str, @@ -280,7 +288,8 @@ def list_by_operation( :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[~azure.mgmt.apimanagement.models.ReportCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] @@ -288,43 +297,41 @@ def list_by_operation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_operation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_operation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ReportCollection', pipeline_response) + deserialized = self._deserialize("ReportCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -337,17 +344,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation'} # type: ignore + @distributed_trace def list_by_product( self, resource_group_name: str, @@ -385,7 +394,8 @@ def list_by_product( :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[~azure.mgmt.apimanagement.models.ReportCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] @@ -393,43 +403,41 @@ def list_by_product( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_product.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_product.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ReportCollection', pipeline_response) + deserialized = self._deserialize("ReportCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -442,17 +450,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct'} # type: ignore + @distributed_trace def list_by_geo( self, resource_group_name: str, @@ -488,7 +498,8 @@ def list_by_geo( :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[~azure.mgmt.apimanagement.models.ReportCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] @@ -496,41 +507,39 @@ def list_by_geo( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_geo.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_geo.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ReportCollection', pipeline_response) + deserialized = self._deserialize("ReportCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -543,17 +552,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_geo.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo'} # type: ignore + @distributed_trace def list_by_subscription( self, resource_group_name: str, @@ -591,7 +602,8 @@ def list_by_subscription( :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[~azure.mgmt.apimanagement.models.ReportCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] @@ -599,43 +611,41 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ReportCollection', pipeline_response) + deserialized = self._deserialize("ReportCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -648,17 +658,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription'} # type: ignore + @distributed_trace def list_by_time( self, resource_group_name: str, @@ -702,7 +714,8 @@ def list_by_time( :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[~azure.mgmt.apimanagement.models.ReportCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] @@ -710,44 +723,43 @@ def list_by_time( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_time.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['interval'] = self._serialize.query("interval", interval, 'duration') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_time.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ReportCollection', pipeline_response) + deserialized = self._deserialize("ReportCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -760,17 +772,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_time.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime'} # type: ignore + @distributed_trace def list_by_request( self, resource_group_name: str, @@ -797,8 +811,10 @@ def list_by_request( :param skip: Number of records to skip. :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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.RequestReportCollection] + :return: An iterator like instance of either RequestReportCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.RequestReportCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RequestReportCollection"] @@ -806,41 +822,39 @@ def list_by_request( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_request.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_request.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RequestReportCollection', pipeline_response) + deserialized = self._deserialize("RequestReportCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -853,12 +867,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_in_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_in_settings_operations.py index 54047e9c33989..96945a7d886be 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 @@ -5,16 +5,20 @@ # 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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_entity_tag( self, resource_group_name: str, @@ -62,44 +67,37 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -122,45 +120,39 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PortalSigninSettings', pipeline_response) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -190,39 +182,29 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PortalSigninSettings') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PortalSigninSettings') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -230,6 +212,8 @@ async def update( update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -259,40 +243,29 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PortalSigninSettings') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PortalSigninSettings') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PortalSigninSettings', pipeline_response) @@ -301,4 +274,6 @@ async def create_or_update( 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 + 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 f2e31f389f827..c031e941ad52c 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 @@ -5,16 +5,20 @@ # 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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_entity_tag( self, resource_group_name: str, @@ -62,44 +67,37 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -122,45 +120,39 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PortalSignupSettings', pipeline_response) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -190,39 +182,29 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PortalSignupSettings') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PortalSignupSettings') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -230,6 +212,8 @@ async def update( update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -259,40 +243,29 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PortalSignupSettings') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PortalSignupSettings') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PortalSignupSettings', pipeline_response) @@ -301,4 +274,6 @@ async def create_or_update( 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 + 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 800700ea05d87..fde6b3a309fe5 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -73,8 +79,10 @@ def list( :param skip: Number of records to skip. :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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionCollection] + :return: An iterator like instance of either SubscriptionCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionCollection"] @@ -82,42 +90,39 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionCollection', pipeline_response) + deserialized = self._deserialize("SubscriptionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -130,17 +135,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -168,45 +175,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -233,46 +233,40 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SubscriptionContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -317,62 +311,54 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if notify is not None: - query_parameters['notify'] = self._serialize.query("notify", notify, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if app_type is not None: - query_parameters['appType'] = self._serialize.query("app_type", app_type, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SubscriptionCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -417,56 +403,48 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if notify is not None: - query_parameters['notify'] = self._serialize.query("notify", notify, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if app_type is not None: - query_parameters['appType'] = self._serialize.query("app_type", app_type, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SubscriptionUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SubscriptionContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -497,35 +475,25 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -533,6 +501,8 @@ async def delete( 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, @@ -559,34 +529,24 @@ async def regenerate_primary_key( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.regenerate_primary_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -594,6 +554,8 @@ async def regenerate_primary_key( 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, @@ -620,34 +582,24 @@ async def regenerate_secondary_key( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.regenerate_secondary_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -655,6 +607,8 @@ async def regenerate_secondary_key( 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, @@ -681,42 +635,35 @@ async def list_secrets( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_secrets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SubscriptionKeysContract', pipeline_response) 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 + 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 8cae2be48bdf1..6ce8464870fe2 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_operation( self, resource_group_name: str, @@ -83,44 +89,43 @@ def list_by_operation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_operation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_operation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagCollection', pipeline_response) + deserialized = self._deserialize("TagCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -133,17 +138,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -177,47 +184,40 @@ async def get_entity_state_by_operation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_state_by_operation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_entity_state_by_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + template_url=self.get_entity_state_by_operation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace_async async def get_by_operation( self, resource_group_name: str, @@ -251,48 +251,42 @@ async def get_by_operation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_by_operation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + template_url=self.get_by_operation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) 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 + + @distributed_trace_async async def assign_to_operation( self, resource_group_name: str, @@ -326,36 +320,26 @@ async def assign_to_operation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.assign_to_operation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_assign_to_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + template_url=self.assign_to_operation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -368,8 +352,11 @@ async def assign_to_operation( 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 + + @distributed_trace_async async def detach_from_operation( self, resource_group_name: str, @@ -403,36 +390,26 @@ async def detach_from_operation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.detach_from_operation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_detach_from_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + template_url=self.detach_from_operation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -440,6 +417,8 @@ async def detach_from_operation( 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( self, resource_group_name: str, @@ -478,43 +457,41 @@ def list_by_api( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_api.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_api.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagCollection', pipeline_response) + deserialized = self._deserialize("TagCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -527,17 +504,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -567,46 +546,39 @@ async def get_entity_state_by_api( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_state_by_api.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace_async async def get_by_api( self, resource_group_name: str, @@ -636,47 +608,41 @@ async def get_by_api( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_by_api.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) 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 + + @distributed_trace_async async def assign_to_api( self, resource_group_name: str, @@ -706,52 +672,47 @@ async def assign_to_api( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.assign_to_api.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def detach_from_api( self, resource_group_name: str, @@ -781,35 +742,25 @@ async def detach_from_api( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.detach_from_api.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -817,6 +768,8 @@ async def detach_from_api( 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( self, resource_group_name: str, @@ -855,43 +808,41 @@ def list_by_product( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_product.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_product.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagCollection', pipeline_response) + deserialized = self._deserialize("TagCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -904,17 +855,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -944,46 +897,39 @@ async def get_entity_state_by_product( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_state_by_product.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace_async async def get_by_product( self, resource_group_name: str, @@ -1013,47 +959,41 @@ async def get_by_product( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_by_product.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) 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 + + @distributed_trace_async async def assign_to_product( self, resource_group_name: str, @@ -1083,35 +1023,25 @@ async def assign_to_product( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.assign_to_product.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -1124,8 +1054,11 @@ async def assign_to_product( 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 + + @distributed_trace_async async def detach_from_product( self, resource_group_name: str, @@ -1155,35 +1088,25 @@ async def detach_from_product( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.detach_from_product.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1191,6 +1114,8 @@ async def detach_from_product( 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( self, resource_group_name: str, @@ -1229,44 +1154,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if scope is not None: - query_parameters['scope'] = self._serialize.query("scope", scope, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagCollection', pipeline_response) + deserialized = self._deserialize("TagCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1279,17 +1201,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -1315,45 +1239,38 @@ async def get_entity_state( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_state.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -1379,46 +1296,40 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -1451,58 +1362,52 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -1535,52 +1440,46 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -1610,38 +1509,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 9331ecb080254..c6866a663dc95 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -77,8 +83,10 @@ def list_by_service( :param skip: Number of records to skip. :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.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] + :return: An iterator like instance of either TagResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] @@ -86,42 +94,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TagResourceCollection', pipeline_response) + deserialized = self._deserialize("TagResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -134,12 +139,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_git_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_git_operations.py index 8dc6e6238564d..bbc2cecfa0724 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 @@ -5,16 +5,20 @@ # 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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def regenerate_primary_key( self, resource_group_name: str, @@ -65,34 +70,24 @@ async def regenerate_primary_key( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.regenerate_primary_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'accessName': self._serialize.url("access_name", access_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -100,6 +95,8 @@ async def regenerate_primary_key( 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, @@ -125,37 +122,28 @@ async def regenerate_secondary_key( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.regenerate_secondary_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'accessName': self._serialize.url("access_name", access_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) 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 + 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 2e00b8c9a500d..e46996010bccd 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -57,8 +63,10 @@ def list_by_service( :param filter: Not used. :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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AccessInformationCollection] + :return: An iterator like instance of either AccessInformationCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AccessInformationCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationCollection"] @@ -66,38 +74,35 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessInformationCollection', pipeline_response) + deserialized = self._deserialize("AccessInformationCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,17 +115,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -146,45 +153,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'accessName': self._serialize.url("access_name", access_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -210,46 +210,40 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'accessName': self._serialize.url("access_name", access_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AccessInformationContract', pipeline_response) 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 + + @distributed_trace_async async def create( self, resource_group_name: str, @@ -282,52 +276,46 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("access_name", access_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AccessInformationCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AccessInformationContract', pipeline_response) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -360,52 +348,46 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("access_name", access_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AccessInformationUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AccessInformationContract', pipeline_response) 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 + + @distributed_trace_async async def regenerate_primary_key( self, resource_group_name: str, @@ -431,34 +413,24 @@ async def regenerate_primary_key( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.regenerate_primary_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'accessName': self._serialize.url("access_name", access_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -466,6 +438,8 @@ async def regenerate_primary_key( 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, @@ -491,34 +465,24 @@ async def regenerate_secondary_key( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.regenerate_secondary_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'accessName': self._serialize.url("access_name", access_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -526,6 +490,8 @@ async def regenerate_secondary_key( 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, @@ -551,42 +517,35 @@ async def list_secrets( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_secrets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'accessName': self._serialize.url("access_name", access_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AccessInformationSecretsContract', pipeline_response) 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 + 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 d7ba3324e1d49..bd6a5ee2f9724 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 @@ -5,18 +5,22 @@ # 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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,40 +59,29 @@ async def _deploy_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._deploy_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeployConfigurationParameters') + + request = build_deploy_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + configuration_name=configuration_name, + content_type=content_type, + json=_json, + template_url=self._deploy_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeployConfigurationParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -98,8 +91,11 @@ async def _deploy_initial( 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 + + @distributed_trace_async async def begin_deploy( self, resource_group_name: str, @@ -121,15 +117,20 @@ async def begin_deploy( :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters :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. + :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: + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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', @@ -142,28 +143,21 @@ async def begin_deploy( service_name=service_name, configuration_name=configuration_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('OperationResultContract', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -175,6 +169,7 @@ def get_long_running_output(pipeline_response): ) else: 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 async def _save_initial( @@ -190,40 +185,29 @@ async def _save_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._save_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'SaveConfigurationParameter') + + request = build_save_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + configuration_name=configuration_name, + content_type=content_type, + json=_json, + template_url=self._save_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SaveConfigurationParameter') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -233,8 +217,11 @@ async def _save_initial( 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 + + @distributed_trace_async async def begin_save( self, resource_group_name: str, @@ -256,15 +243,20 @@ async def begin_save( :type parameters: ~azure.mgmt.apimanagement.models.SaveConfigurationParameter :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. + :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: + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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', @@ -277,28 +269,21 @@ async def begin_save( service_name=service_name, configuration_name=configuration_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('OperationResultContract', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -310,6 +295,7 @@ def get_long_running_output(pipeline_response): ) else: 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 async def _validate_initial( @@ -325,40 +311,29 @@ async def _validate_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DeployConfigurationParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + configuration_name=configuration_name, + content_type=content_type, + json=_json, + template_url=self._validate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeployConfigurationParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -368,8 +343,11 @@ async def _validate_initial( 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 + + @distributed_trace_async async def begin_validate( self, resource_group_name: str, @@ -391,15 +369,20 @@ async def begin_validate( :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters :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. + :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: + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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', @@ -412,28 +395,21 @@ async def begin_validate( service_name=service_name, configuration_name=configuration_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('OperationResultContract', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -445,8 +421,10 @@ def get_long_running_output(pipeline_response): ) else: 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 + @distributed_trace_async async def get_sync_state( self, resource_group_name: str, @@ -473,34 +451,24 @@ async def get_sync_state( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_sync_state.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TenantConfigurationSyncStateContract', pipeline_response) @@ -509,4 +477,6 @@ async def get_sync_state( 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 + 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 6e0cd8cd4ee9e..6a124c211e1c4 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -57,8 +63,10 @@ def list_by_service( :param filter: Not used. :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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TenantSettingsCollection] + :return: An iterator like instance of either TenantSettingsCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TenantSettingsCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantSettingsCollection"] @@ -66,38 +74,35 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TenantSettingsCollection', pipeline_response) + deserialized = self._deserialize("TenantSettingsCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,17 +115,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -146,42 +153,35 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'settingsType': self._serialize.url("settings_type", settings_type, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TenantSettingsContract', pipeline_response) 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 + 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 79a758b705b98..5a2f963d9f757 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 @@ -5,16 +5,20 @@ # 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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def send( self, resource_group_name: str, @@ -69,39 +74,29 @@ async def send( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.send.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if app_type is not None: - query_parameters['appType'] = self._serialize.query("app_type", app_type, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) 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 + 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 1f67b6ed4dbab..cc858d71458ca 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -73,7 +79,8 @@ def list( :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[~azure.mgmt.apimanagement.models.GroupCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GroupCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupCollection"] @@ -81,43 +88,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('GroupCollection', pipeline_response) + deserialized = self._deserialize("GroupCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -130,12 +135,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_identities_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_identities_operations.py index fea02ac5029d0..b20a5c8f302bf 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -57,8 +63,10 @@ def list( :param user_id: User identifier. Must be unique in the current API Management service instance. :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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.UserIdentityCollection] + :return: An iterator like instance of either UserIdentityCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.UserIdentityCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.UserIdentityCollection"] @@ -66,37 +74,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UserIdentityCollection', pipeline_response) + deserialized = self._deserialize("UserIdentityCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,12 +115,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_operations.py index c1c00e2ad76e1..c28f4b8592411 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, resource_group_name: str, @@ -75,7 +81,8 @@ def list_by_service( :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[~azure.mgmt.apimanagement.models.UserCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.UserCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.UserCollection"] @@ -83,44 +90,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if expand_groups is not None: - query_parameters['expandGroups'] = self._serialize.query("expand_groups", expand_groups, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UserCollection', pipeline_response) + deserialized = self._deserialize("UserCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -133,17 +137,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -169,45 +175,38 @@ async def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, @@ -233,46 +232,40 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('UserContract', pipeline_response) 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 + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -308,60 +301,53 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if notify is not None: - query_parameters['notify'] = self._serialize.query("notify", notify, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UserCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -394,52 +380,46 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UserUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('UserContract', pipeline_response) 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -479,41 +459,28 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if delete_subscriptions is not None: - query_parameters['deleteSubscriptions'] = self._serialize.query("delete_subscriptions", delete_subscriptions, 'bool') - if notify is not None: - query_parameters['notify'] = self._serialize.query("notify", notify, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if app_type is not None: - query_parameters['appType'] = self._serialize.query("app_type", app_type, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) + + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + delete_subscriptions=delete_subscriptions, + notify=notify, + app_type=app_type, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -521,6 +488,8 @@ async def delete( 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, @@ -547,34 +516,24 @@ async def generate_sso_url( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.generate_sso_url.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GenerateSsoUrlResult', pipeline_response) @@ -583,8 +542,11 @@ async def generate_sso_url( 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 + + @distributed_trace_async async def get_shared_access_token( self, resource_group_name: str, @@ -613,39 +575,29 @@ async def get_shared_access_token( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.get_shared_access_token.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'UserTokenParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + 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, + content_type=content_type, + json=_json, + template_url=self.get_shared_access_token.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UserTokenParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UserTokenResult', pipeline_response) @@ -654,4 +606,6 @@ async def get_shared_access_token( 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 + 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 772fbc8c9a6e1..eec3dc668d652 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 @@ -5,17 +5,22 @@ # 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 azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +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.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') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name: str, @@ -75,8 +81,10 @@ def list( :param skip: Number of records to skip. :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 cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionCollection] + :return: An iterator like instance of either SubscriptionCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionCollection"] @@ -84,43 +92,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionCollection', pipeline_response) + deserialized = self._deserialize("SubscriptionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -133,17 +139,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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, @@ -173,43 +181,36 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'sid': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SubscriptionContract', pipeline_response) 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 + 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 e329c40fad4e4..d83a3cafb3e34 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 @@ -6,545 +6,307 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AccessInformationCollection - from ._models_py3 import AccessInformationContract - from ._models_py3 import AccessInformationCreateParameters - from ._models_py3 import AccessInformationSecretsContract - from ._models_py3 import AccessInformationUpdateParameters - from ._models_py3 import AdditionalLocation - from ._models_py3 import ApiCollection - from ._models_py3 import ApiContract - from ._models_py3 import ApiContractProperties - from ._models_py3 import ApiContractUpdateProperties - from ._models_py3 import ApiCreateOrUpdateParameter - from ._models_py3 import ApiCreateOrUpdateProperties - from ._models_py3 import ApiCreateOrUpdatePropertiesWsdlSelector - from ._models_py3 import ApiEntityBaseContract - from ._models_py3 import ApiExportResult - from ._models_py3 import ApiExportResultValue - from ._models_py3 import ApiManagementServiceApplyNetworkConfigurationParameters - from ._models_py3 import ApiManagementServiceBackupRestoreParameters - from ._models_py3 import ApiManagementServiceBaseProperties - from ._models_py3 import ApiManagementServiceCheckNameAvailabilityParameters - from ._models_py3 import ApiManagementServiceGetDomainOwnershipIdentifierResult - from ._models_py3 import ApiManagementServiceGetSsoTokenResult - from ._models_py3 import ApiManagementServiceIdentity - from ._models_py3 import ApiManagementServiceListResult - from ._models_py3 import ApiManagementServiceNameAvailabilityResult - from ._models_py3 import ApiManagementServiceProperties - from ._models_py3 import ApiManagementServiceResource - from ._models_py3 import ApiManagementServiceSkuProperties - from ._models_py3 import ApiManagementServiceUpdateParameters - from ._models_py3 import ApiManagementServiceUpdateProperties - from ._models_py3 import ApiManagementSku - from ._models_py3 import ApiManagementSkuCapabilities - from ._models_py3 import ApiManagementSkuCapacity - from ._models_py3 import ApiManagementSkuCosts - from ._models_py3 import ApiManagementSkuLocationInfo - from ._models_py3 import ApiManagementSkuRestrictionInfo - from ._models_py3 import ApiManagementSkuRestrictions - from ._models_py3 import ApiManagementSkuZoneDetails - from ._models_py3 import ApiManagementSkusResult - from ._models_py3 import ApiReleaseCollection - from ._models_py3 import ApiReleaseContract - from ._models_py3 import ApiRevisionCollection - from ._models_py3 import ApiRevisionContract - from ._models_py3 import ApiRevisionInfoContract - from ._models_py3 import ApiTagResourceContractProperties - from ._models_py3 import ApiUpdateContract - from ._models_py3 import ApiVersionConstraint - from ._models_py3 import ApiVersionSetCollection - from ._models_py3 import ApiVersionSetContract - from ._models_py3 import ApiVersionSetContractDetails - from ._models_py3 import ApiVersionSetContractProperties - from ._models_py3 import ApiVersionSetEntityBase - from ._models_py3 import ApiVersionSetUpdateParameters - from ._models_py3 import ApiVersionSetUpdateParametersProperties - from ._models_py3 import ApimResource - from ._models_py3 import AssociationContract - from ._models_py3 import AuthenticationSettingsContract - from ._models_py3 import AuthorizationServerCollection - from ._models_py3 import AuthorizationServerContract - from ._models_py3 import AuthorizationServerContractBaseProperties - from ._models_py3 import AuthorizationServerContractProperties - from ._models_py3 import AuthorizationServerSecretsContract - from ._models_py3 import AuthorizationServerUpdateContract - from ._models_py3 import AuthorizationServerUpdateContractProperties - from ._models_py3 import BackendAuthorizationHeaderCredentials - from ._models_py3 import BackendBaseParameters - from ._models_py3 import BackendCollection - from ._models_py3 import BackendContract - from ._models_py3 import BackendContractProperties - from ._models_py3 import BackendCredentialsContract - from ._models_py3 import BackendProperties - from ._models_py3 import BackendProxyContract - from ._models_py3 import BackendReconnectContract - from ._models_py3 import BackendServiceFabricClusterProperties - from ._models_py3 import BackendTlsProperties - from ._models_py3 import BackendUpdateParameterProperties - from ._models_py3 import BackendUpdateParameters - from ._models_py3 import BodyDiagnosticSettings - from ._models_py3 import CacheCollection - from ._models_py3 import CacheContract - from ._models_py3 import CacheUpdateParameters - from ._models_py3 import CertificateCollection - from ._models_py3 import CertificateConfiguration - from ._models_py3 import CertificateContract - from ._models_py3 import CertificateCreateOrUpdateParameters - from ._models_py3 import CertificateInformation - from ._models_py3 import ClientSecretContract - from ._models_py3 import ConnectivityStatusContract - from ._models_py3 import ContentItemCollection - from ._models_py3 import ContentItemContract - from ._models_py3 import ContentTypeCollection - from ._models_py3 import ContentTypeContract - from ._models_py3 import DataMasking - from ._models_py3 import DataMaskingEntity - from ._models_py3 import DeletedServiceContract - from ._models_py3 import DeletedServicesCollection - from ._models_py3 import DeployConfigurationParameters - from ._models_py3 import DiagnosticCollection - from ._models_py3 import DiagnosticContract - from ._models_py3 import EmailTemplateCollection - from ._models_py3 import EmailTemplateContract - from ._models_py3 import EmailTemplateParametersContractProperties - from ._models_py3 import EmailTemplateUpdateParameters - from ._models_py3 import ErrorFieldContract - from ._models_py3 import ErrorResponse - from ._models_py3 import ErrorResponseBody - from ._models_py3 import GatewayCertificateAuthorityCollection - from ._models_py3 import GatewayCertificateAuthorityContract - from ._models_py3 import GatewayCollection - from ._models_py3 import GatewayContract - from ._models_py3 import GatewayHostnameConfigurationCollection - from ._models_py3 import GatewayHostnameConfigurationContract - from ._models_py3 import GatewayKeyRegenerationRequestContract - from ._models_py3 import GatewayKeysContract - from ._models_py3 import GatewayTokenContract - from ._models_py3 import GatewayTokenRequestContract - from ._models_py3 import GenerateSsoUrlResult - from ._models_py3 import GroupCollection - from ._models_py3 import GroupContract - from ._models_py3 import GroupContractProperties - from ._models_py3 import GroupCreateParameters - from ._models_py3 import GroupUpdateParameters - from ._models_py3 import HostnameConfiguration - from ._models_py3 import HttpMessageDiagnostic - from ._models_py3 import IdentityProviderBaseParameters - from ._models_py3 import IdentityProviderContract - from ._models_py3 import IdentityProviderContractProperties - from ._models_py3 import IdentityProviderCreateContract - from ._models_py3 import IdentityProviderCreateContractProperties - from ._models_py3 import IdentityProviderList - from ._models_py3 import IdentityProviderUpdateParameters - from ._models_py3 import IdentityProviderUpdateProperties - from ._models_py3 import IssueAttachmentCollection - from ._models_py3 import IssueAttachmentContract - from ._models_py3 import IssueCollection - from ._models_py3 import IssueCommentCollection - from ._models_py3 import IssueCommentContract - from ._models_py3 import IssueContract - from ._models_py3 import IssueContractBaseProperties - from ._models_py3 import IssueContractProperties - from ._models_py3 import IssueUpdateContract - from ._models_py3 import IssueUpdateContractProperties - from ._models_py3 import KeyVaultContractCreateProperties - from ._models_py3 import KeyVaultContractProperties - from ._models_py3 import KeyVaultLastAccessStatusContractProperties - from ._models_py3 import LoggerCollection - from ._models_py3 import LoggerContract - from ._models_py3 import LoggerUpdateContract - from ._models_py3 import NamedValueCollection - from ._models_py3 import NamedValueContract - from ._models_py3 import NamedValueContractProperties - from ._models_py3 import NamedValueCreateContract - from ._models_py3 import NamedValueCreateContractProperties - from ._models_py3 import NamedValueEntityBaseParameters - from ._models_py3 import NamedValueSecretContract - from ._models_py3 import NamedValueUpdateParameterProperties - from ._models_py3 import NamedValueUpdateParameters - from ._models_py3 import NetworkStatusContract - from ._models_py3 import NetworkStatusContractByLocation - from ._models_py3 import NotificationCollection - from ._models_py3 import NotificationContract - from ._models_py3 import OAuth2AuthenticationSettingsContract - from ._models_py3 import OpenIdAuthenticationSettingsContract - from ._models_py3 import OpenIdConnectProviderCollection - from ._models_py3 import OpenidConnectProviderContract - from ._models_py3 import OpenidConnectProviderUpdateContract - from ._models_py3 import Operation - from ._models_py3 import OperationCollection - from ._models_py3 import OperationContract - from ._models_py3 import OperationContractProperties - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationEntityBaseContract - from ._models_py3 import OperationListResult - from ._models_py3 import OperationResultContract - from ._models_py3 import OperationResultLogItemContract - from ._models_py3 import OperationTagResourceContractProperties - from ._models_py3 import OperationUpdateContract - from ._models_py3 import OperationUpdateContractProperties - from ._models_py3 import ParameterContract - from ._models_py3 import PipelineDiagnosticSettings - from ._models_py3 import PolicyCollection - from ._models_py3 import PolicyContract - from ._models_py3 import PolicyDescriptionCollection - from ._models_py3 import PolicyDescriptionContract - from ._models_py3 import PortalDelegationSettings - from ._models_py3 import PortalRevisionCollection - from ._models_py3 import PortalRevisionContract - from ._models_py3 import PortalSettingValidationKeyContract - from ._models_py3 import PortalSettingsCollection - from ._models_py3 import PortalSettingsContract - from ._models_py3 import PortalSigninSettings - from ._models_py3 import PortalSignupSettings - from ._models_py3 import ProductCollection - from ._models_py3 import ProductContract - from ._models_py3 import ProductContractProperties - from ._models_py3 import ProductEntityBaseParameters - from ._models_py3 import ProductTagResourceContractProperties - from ._models_py3 import ProductUpdateParameters - from ._models_py3 import ProductUpdateProperties - from ._models_py3 import QuotaCounterCollection - from ._models_py3 import QuotaCounterContract - from ._models_py3 import QuotaCounterValueContract - from ._models_py3 import QuotaCounterValueContractProperties - from ._models_py3 import QuotaCounterValueUpdateContract - from ._models_py3 import RecipientEmailCollection - from ._models_py3 import RecipientEmailContract - from ._models_py3 import RecipientUserCollection - from ._models_py3 import RecipientUserContract - from ._models_py3 import RecipientsContractProperties - from ._models_py3 import RegionContract - from ._models_py3 import RegionListResult - from ._models_py3 import RegistrationDelegationSettingsProperties - from ._models_py3 import ReportCollection - from ._models_py3 import ReportRecordContract - from ._models_py3 import RepresentationContract - from ._models_py3 import RequestContract - from ._models_py3 import RequestReportCollection - from ._models_py3 import RequestReportRecordContract - from ._models_py3 import Resource - from ._models_py3 import ResourceLocationDataContract - from ._models_py3 import ResourceSku - from ._models_py3 import ResourceSkuCapacity - from ._models_py3 import ResourceSkuResult - from ._models_py3 import ResourceSkuResults - from ._models_py3 import ResponseContract - from ._models_py3 import SamplingSettings - from ._models_py3 import SaveConfigurationParameter - from ._models_py3 import SchemaCollection - from ._models_py3 import SchemaContract - from ._models_py3 import SubscriptionCollection - from ._models_py3 import SubscriptionContract - from ._models_py3 import SubscriptionCreateParameters - from ._models_py3 import SubscriptionKeyParameterNamesContract - from ._models_py3 import SubscriptionKeysContract - from ._models_py3 import SubscriptionUpdateParameters - from ._models_py3 import SubscriptionsDelegationSettingsProperties - from ._models_py3 import TagCollection - from ._models_py3 import TagContract - from ._models_py3 import TagCreateUpdateParameters - from ._models_py3 import TagDescriptionBaseProperties - from ._models_py3 import TagDescriptionCollection - from ._models_py3 import TagDescriptionContract - from ._models_py3 import TagDescriptionContractProperties - from ._models_py3 import TagDescriptionCreateParameters - from ._models_py3 import TagResourceCollection - from ._models_py3 import TagResourceContract - from ._models_py3 import TagResourceContractProperties - from ._models_py3 import TenantConfigurationSyncStateContract - from ._models_py3 import TenantSettingsCollection - from ._models_py3 import TenantSettingsContract - from ._models_py3 import TermsOfServiceProperties - from ._models_py3 import TokenBodyParameterContract - from ._models_py3 import UserCollection - from ._models_py3 import UserContract - from ._models_py3 import UserContractProperties - from ._models_py3 import UserCreateParameterProperties - from ._models_py3 import UserCreateParameters - from ._models_py3 import UserEntityBaseParameters - from ._models_py3 import UserIdentityCollection - from ._models_py3 import UserIdentityContract - from ._models_py3 import UserIdentityProperties - from ._models_py3 import UserTokenParameters - from ._models_py3 import UserTokenResult - from ._models_py3 import UserUpdateParameters - from ._models_py3 import UserUpdateParametersProperties - from ._models_py3 import VirtualNetworkConfiguration - from ._models_py3 import X509CertificateName -except (SyntaxError, ImportError): - from ._models import AccessInformationCollection # type: ignore - from ._models import AccessInformationContract # type: ignore - from ._models import AccessInformationCreateParameters # type: ignore - from ._models import AccessInformationSecretsContract # type: ignore - from ._models import AccessInformationUpdateParameters # type: ignore - from ._models import AdditionalLocation # type: ignore - from ._models import ApiCollection # type: ignore - from ._models import ApiContract # type: ignore - from ._models import ApiContractProperties # type: ignore - from ._models import ApiContractUpdateProperties # type: ignore - from ._models import ApiCreateOrUpdateParameter # type: ignore - from ._models import ApiCreateOrUpdateProperties # type: ignore - from ._models import ApiCreateOrUpdatePropertiesWsdlSelector # type: ignore - from ._models import ApiEntityBaseContract # type: ignore - from ._models import ApiExportResult # type: ignore - from ._models import ApiExportResultValue # type: ignore - from ._models import ApiManagementServiceApplyNetworkConfigurationParameters # type: ignore - from ._models import ApiManagementServiceBackupRestoreParameters # type: ignore - from ._models import ApiManagementServiceBaseProperties # type: ignore - from ._models import ApiManagementServiceCheckNameAvailabilityParameters # type: ignore - from ._models import ApiManagementServiceGetDomainOwnershipIdentifierResult # type: ignore - from ._models import ApiManagementServiceGetSsoTokenResult # type: ignore - from ._models import ApiManagementServiceIdentity # type: ignore - from ._models import ApiManagementServiceListResult # type: ignore - from ._models import ApiManagementServiceNameAvailabilityResult # type: ignore - from ._models import ApiManagementServiceProperties # type: ignore - from ._models import ApiManagementServiceResource # type: ignore - from ._models import ApiManagementServiceSkuProperties # type: ignore - from ._models import ApiManagementServiceUpdateParameters # type: ignore - from ._models import ApiManagementServiceUpdateProperties # type: ignore - from ._models import ApiManagementSku # type: ignore - from ._models import ApiManagementSkuCapabilities # type: ignore - from ._models import ApiManagementSkuCapacity # type: ignore - from ._models import ApiManagementSkuCosts # type: ignore - from ._models import ApiManagementSkuLocationInfo # type: ignore - from ._models import ApiManagementSkuRestrictionInfo # type: ignore - from ._models import ApiManagementSkuRestrictions # type: ignore - from ._models import ApiManagementSkuZoneDetails # type: ignore - from ._models import ApiManagementSkusResult # type: ignore - from ._models import ApiReleaseCollection # type: ignore - from ._models import ApiReleaseContract # type: ignore - from ._models import ApiRevisionCollection # type: ignore - from ._models import ApiRevisionContract # type: ignore - from ._models import ApiRevisionInfoContract # type: ignore - from ._models import ApiTagResourceContractProperties # type: ignore - from ._models import ApiUpdateContract # type: ignore - from ._models import ApiVersionConstraint # type: ignore - from ._models import ApiVersionSetCollection # type: ignore - from ._models import ApiVersionSetContract # type: ignore - from ._models import ApiVersionSetContractDetails # type: ignore - from ._models import ApiVersionSetContractProperties # type: ignore - from ._models import ApiVersionSetEntityBase # type: ignore - from ._models import ApiVersionSetUpdateParameters # type: ignore - from ._models import ApiVersionSetUpdateParametersProperties # type: ignore - from ._models import ApimResource # type: ignore - from ._models import AssociationContract # type: ignore - from ._models import AuthenticationSettingsContract # type: ignore - from ._models import AuthorizationServerCollection # type: ignore - from ._models import AuthorizationServerContract # type: ignore - from ._models import AuthorizationServerContractBaseProperties # type: ignore - from ._models import AuthorizationServerContractProperties # type: ignore - from ._models import AuthorizationServerSecretsContract # type: ignore - from ._models import AuthorizationServerUpdateContract # type: ignore - from ._models import AuthorizationServerUpdateContractProperties # type: ignore - from ._models import BackendAuthorizationHeaderCredentials # type: ignore - from ._models import BackendBaseParameters # type: ignore - from ._models import BackendCollection # type: ignore - from ._models import BackendContract # type: ignore - from ._models import BackendContractProperties # type: ignore - from ._models import BackendCredentialsContract # type: ignore - from ._models import BackendProperties # type: ignore - from ._models import BackendProxyContract # type: ignore - from ._models import BackendReconnectContract # type: ignore - from ._models import BackendServiceFabricClusterProperties # type: ignore - from ._models import BackendTlsProperties # type: ignore - from ._models import BackendUpdateParameterProperties # type: ignore - from ._models import BackendUpdateParameters # type: ignore - from ._models import BodyDiagnosticSettings # type: ignore - from ._models import CacheCollection # type: ignore - from ._models import CacheContract # type: ignore - from ._models import CacheUpdateParameters # type: ignore - from ._models import CertificateCollection # type: ignore - from ._models import CertificateConfiguration # type: ignore - from ._models import CertificateContract # type: ignore - from ._models import CertificateCreateOrUpdateParameters # type: ignore - from ._models import CertificateInformation # type: ignore - from ._models import ClientSecretContract # type: ignore - from ._models import ConnectivityStatusContract # type: ignore - from ._models import ContentItemCollection # type: ignore - from ._models import ContentItemContract # type: ignore - from ._models import ContentTypeCollection # type: ignore - from ._models import ContentTypeContract # type: ignore - from ._models import DataMasking # type: ignore - from ._models import DataMaskingEntity # type: ignore - from ._models import DeletedServiceContract # type: ignore - from ._models import DeletedServicesCollection # type: ignore - from ._models import DeployConfigurationParameters # type: ignore - from ._models import DiagnosticCollection # type: ignore - from ._models import DiagnosticContract # type: ignore - from ._models import EmailTemplateCollection # type: ignore - from ._models import EmailTemplateContract # type: ignore - from ._models import EmailTemplateParametersContractProperties # type: ignore - from ._models import EmailTemplateUpdateParameters # type: ignore - from ._models import ErrorFieldContract # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ErrorResponseBody # type: ignore - from ._models import GatewayCertificateAuthorityCollection # type: ignore - from ._models import GatewayCertificateAuthorityContract # type: ignore - from ._models import GatewayCollection # type: ignore - from ._models import GatewayContract # type: ignore - from ._models import GatewayHostnameConfigurationCollection # type: ignore - from ._models import GatewayHostnameConfigurationContract # type: ignore - from ._models import GatewayKeyRegenerationRequestContract # type: ignore - from ._models import GatewayKeysContract # type: ignore - from ._models import GatewayTokenContract # type: ignore - from ._models import GatewayTokenRequestContract # type: ignore - from ._models import GenerateSsoUrlResult # type: ignore - from ._models import GroupCollection # type: ignore - from ._models import GroupContract # type: ignore - from ._models import GroupContractProperties # type: ignore - from ._models import GroupCreateParameters # type: ignore - from ._models import GroupUpdateParameters # type: ignore - from ._models import HostnameConfiguration # type: ignore - from ._models import HttpMessageDiagnostic # type: ignore - from ._models import IdentityProviderBaseParameters # type: ignore - from ._models import IdentityProviderContract # type: ignore - from ._models import IdentityProviderContractProperties # type: ignore - from ._models import IdentityProviderCreateContract # type: ignore - from ._models import IdentityProviderCreateContractProperties # type: ignore - from ._models import IdentityProviderList # type: ignore - from ._models import IdentityProviderUpdateParameters # type: ignore - from ._models import IdentityProviderUpdateProperties # type: ignore - from ._models import IssueAttachmentCollection # type: ignore - from ._models import IssueAttachmentContract # type: ignore - from ._models import IssueCollection # type: ignore - from ._models import IssueCommentCollection # type: ignore - from ._models import IssueCommentContract # type: ignore - from ._models import IssueContract # type: ignore - from ._models import IssueContractBaseProperties # type: ignore - from ._models import IssueContractProperties # type: ignore - from ._models import IssueUpdateContract # type: ignore - from ._models import IssueUpdateContractProperties # type: ignore - from ._models import KeyVaultContractCreateProperties # type: ignore - from ._models import KeyVaultContractProperties # type: ignore - from ._models import KeyVaultLastAccessStatusContractProperties # type: ignore - from ._models import LoggerCollection # type: ignore - from ._models import LoggerContract # type: ignore - from ._models import LoggerUpdateContract # type: ignore - from ._models import NamedValueCollection # type: ignore - from ._models import NamedValueContract # type: ignore - from ._models import NamedValueContractProperties # type: ignore - from ._models import NamedValueCreateContract # type: ignore - from ._models import NamedValueCreateContractProperties # type: ignore - from ._models import NamedValueEntityBaseParameters # type: ignore - from ._models import NamedValueSecretContract # type: ignore - from ._models import NamedValueUpdateParameterProperties # type: ignore - from ._models import NamedValueUpdateParameters # type: ignore - from ._models import NetworkStatusContract # type: ignore - from ._models import NetworkStatusContractByLocation # type: ignore - from ._models import NotificationCollection # type: ignore - from ._models import NotificationContract # type: ignore - from ._models import OAuth2AuthenticationSettingsContract # type: ignore - from ._models import OpenIdAuthenticationSettingsContract # type: ignore - from ._models import OpenIdConnectProviderCollection # type: ignore - from ._models import OpenidConnectProviderContract # type: ignore - from ._models import OpenidConnectProviderUpdateContract # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationCollection # type: ignore - from ._models import OperationContract # type: ignore - from ._models import OperationContractProperties # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationEntityBaseContract # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import OperationResultContract # type: ignore - from ._models import OperationResultLogItemContract # type: ignore - from ._models import OperationTagResourceContractProperties # type: ignore - from ._models import OperationUpdateContract # type: ignore - from ._models import OperationUpdateContractProperties # type: ignore - from ._models import ParameterContract # type: ignore - from ._models import PipelineDiagnosticSettings # type: ignore - from ._models import PolicyCollection # type: ignore - from ._models import PolicyContract # type: ignore - from ._models import PolicyDescriptionCollection # type: ignore - from ._models import PolicyDescriptionContract # type: ignore - from ._models import PortalDelegationSettings # type: ignore - from ._models import PortalRevisionCollection # type: ignore - from ._models import PortalRevisionContract # type: ignore - from ._models import PortalSettingValidationKeyContract # type: ignore - from ._models import PortalSettingsCollection # type: ignore - from ._models import PortalSettingsContract # type: ignore - from ._models import PortalSigninSettings # type: ignore - from ._models import PortalSignupSettings # type: ignore - from ._models import ProductCollection # type: ignore - from ._models import ProductContract # type: ignore - from ._models import ProductContractProperties # type: ignore - from ._models import ProductEntityBaseParameters # type: ignore - from ._models import ProductTagResourceContractProperties # type: ignore - from ._models import ProductUpdateParameters # type: ignore - from ._models import ProductUpdateProperties # type: ignore - from ._models import QuotaCounterCollection # type: ignore - from ._models import QuotaCounterContract # type: ignore - from ._models import QuotaCounterValueContract # type: ignore - from ._models import QuotaCounterValueContractProperties # type: ignore - from ._models import QuotaCounterValueUpdateContract # type: ignore - from ._models import RecipientEmailCollection # type: ignore - from ._models import RecipientEmailContract # type: ignore - from ._models import RecipientUserCollection # type: ignore - from ._models import RecipientUserContract # type: ignore - from ._models import RecipientsContractProperties # type: ignore - from ._models import RegionContract # type: ignore - from ._models import RegionListResult # type: ignore - from ._models import RegistrationDelegationSettingsProperties # type: ignore - from ._models import ReportCollection # type: ignore - from ._models import ReportRecordContract # type: ignore - from ._models import RepresentationContract # type: ignore - from ._models import RequestContract # type: ignore - from ._models import RequestReportCollection # type: ignore - from ._models import RequestReportRecordContract # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourceLocationDataContract # type: ignore - from ._models import ResourceSku # type: ignore - from ._models import ResourceSkuCapacity # type: ignore - from ._models import ResourceSkuResult # type: ignore - from ._models import ResourceSkuResults # type: ignore - from ._models import ResponseContract # type: ignore - from ._models import SamplingSettings # type: ignore - from ._models import SaveConfigurationParameter # type: ignore - from ._models import SchemaCollection # type: ignore - from ._models import SchemaContract # type: ignore - from ._models import SubscriptionCollection # type: ignore - from ._models import SubscriptionContract # type: ignore - from ._models import SubscriptionCreateParameters # type: ignore - from ._models import SubscriptionKeyParameterNamesContract # type: ignore - from ._models import SubscriptionKeysContract # type: ignore - from ._models import SubscriptionUpdateParameters # type: ignore - from ._models import SubscriptionsDelegationSettingsProperties # type: ignore - from ._models import TagCollection # type: ignore - from ._models import TagContract # type: ignore - from ._models import TagCreateUpdateParameters # type: ignore - from ._models import TagDescriptionBaseProperties # type: ignore - from ._models import TagDescriptionCollection # type: ignore - from ._models import TagDescriptionContract # type: ignore - from ._models import TagDescriptionContractProperties # type: ignore - from ._models import TagDescriptionCreateParameters # type: ignore - from ._models import TagResourceCollection # type: ignore - from ._models import TagResourceContract # type: ignore - from ._models import TagResourceContractProperties # type: ignore - from ._models import TenantConfigurationSyncStateContract # type: ignore - from ._models import TenantSettingsCollection # type: ignore - from ._models import TenantSettingsContract # type: ignore - from ._models import TermsOfServiceProperties # type: ignore - from ._models import TokenBodyParameterContract # type: ignore - from ._models import UserCollection # type: ignore - from ._models import UserContract # type: ignore - from ._models import UserContractProperties # type: ignore - from ._models import UserCreateParameterProperties # type: ignore - from ._models import UserCreateParameters # type: ignore - from ._models import UserEntityBaseParameters # type: ignore - from ._models import UserIdentityCollection # type: ignore - from ._models import UserIdentityContract # type: ignore - from ._models import UserIdentityProperties # type: ignore - from ._models import UserTokenParameters # type: ignore - from ._models import UserTokenResult # type: ignore - from ._models import UserUpdateParameters # type: ignore - from ._models import UserUpdateParametersProperties # type: ignore - from ._models import VirtualNetworkConfiguration # type: ignore - from ._models import X509CertificateName # type: ignore +from ._models_py3 import AccessInformationCollection +from ._models_py3 import AccessInformationContract +from ._models_py3 import AccessInformationCreateParameters +from ._models_py3 import AccessInformationSecretsContract +from ._models_py3 import AccessInformationUpdateParameters +from ._models_py3 import AdditionalLocation +from ._models_py3 import ApiCollection +from ._models_py3 import ApiContactInformation +from ._models_py3 import ApiContract +from ._models_py3 import ApiContractProperties +from ._models_py3 import ApiContractUpdateProperties +from ._models_py3 import ApiCreateOrUpdateParameter +from ._models_py3 import ApiCreateOrUpdateProperties +from ._models_py3 import ApiCreateOrUpdatePropertiesWsdlSelector +from ._models_py3 import ApiEntityBaseContract +from ._models_py3 import ApiExportResult +from ._models_py3 import ApiExportResultValue +from ._models_py3 import ApiLicenseInformation +from ._models_py3 import ApiManagementServiceApplyNetworkConfigurationParameters +from ._models_py3 import ApiManagementServiceBackupRestoreParameters +from ._models_py3 import ApiManagementServiceBaseProperties +from ._models_py3 import ApiManagementServiceCheckNameAvailabilityParameters +from ._models_py3 import ApiManagementServiceGetDomainOwnershipIdentifierResult +from ._models_py3 import ApiManagementServiceGetSsoTokenResult +from ._models_py3 import ApiManagementServiceIdentity +from ._models_py3 import ApiManagementServiceListResult +from ._models_py3 import ApiManagementServiceNameAvailabilityResult +from ._models_py3 import ApiManagementServiceProperties +from ._models_py3 import ApiManagementServiceResource +from ._models_py3 import ApiManagementServiceSkuProperties +from ._models_py3 import ApiManagementServiceUpdateParameters +from ._models_py3 import ApiManagementServiceUpdateProperties +from ._models_py3 import ApiManagementSku +from ._models_py3 import ApiManagementSkuCapabilities +from ._models_py3 import ApiManagementSkuCapacity +from ._models_py3 import ApiManagementSkuCosts +from ._models_py3 import ApiManagementSkuLocationInfo +from ._models_py3 import ApiManagementSkuRestrictionInfo +from ._models_py3 import ApiManagementSkuRestrictions +from ._models_py3 import ApiManagementSkuZoneDetails +from ._models_py3 import ApiManagementSkusResult +from ._models_py3 import ApiReleaseCollection +from ._models_py3 import ApiReleaseContract +from ._models_py3 import ApiRevisionCollection +from ._models_py3 import ApiRevisionContract +from ._models_py3 import ApiRevisionInfoContract +from ._models_py3 import ApiTagResourceContractProperties +from ._models_py3 import ApiUpdateContract +from ._models_py3 import ApiVersionConstraint +from ._models_py3 import ApiVersionSetCollection +from ._models_py3 import ApiVersionSetContract +from ._models_py3 import ApiVersionSetContractDetails +from ._models_py3 import ApiVersionSetContractProperties +from ._models_py3 import ApiVersionSetEntityBase +from ._models_py3 import ApiVersionSetUpdateParameters +from ._models_py3 import ApiVersionSetUpdateParametersProperties +from ._models_py3 import ApimResource +from ._models_py3 import ArmIdWrapper +from ._models_py3 import AssociationContract +from ._models_py3 import AuthenticationSettingsContract +from ._models_py3 import AuthorizationServerCollection +from ._models_py3 import AuthorizationServerContract +from ._models_py3 import AuthorizationServerContractBaseProperties +from ._models_py3 import AuthorizationServerContractProperties +from ._models_py3 import AuthorizationServerSecretsContract +from ._models_py3 import AuthorizationServerUpdateContract +from ._models_py3 import AuthorizationServerUpdateContractProperties +from ._models_py3 import BackendAuthorizationHeaderCredentials +from ._models_py3 import BackendBaseParameters +from ._models_py3 import BackendCollection +from ._models_py3 import BackendContract +from ._models_py3 import BackendContractProperties +from ._models_py3 import BackendCredentialsContract +from ._models_py3 import BackendProperties +from ._models_py3 import BackendProxyContract +from ._models_py3 import BackendReconnectContract +from ._models_py3 import BackendServiceFabricClusterProperties +from ._models_py3 import BackendTlsProperties +from ._models_py3 import BackendUpdateParameterProperties +from ._models_py3 import BackendUpdateParameters +from ._models_py3 import BodyDiagnosticSettings +from ._models_py3 import CacheCollection +from ._models_py3 import CacheContract +from ._models_py3 import CacheUpdateParameters +from ._models_py3 import CertificateCollection +from ._models_py3 import CertificateConfiguration +from ._models_py3 import CertificateContract +from ._models_py3 import CertificateCreateOrUpdateParameters +from ._models_py3 import CertificateInformation +from ._models_py3 import ClientSecretContract +from ._models_py3 import ConnectivityCheckRequest +from ._models_py3 import ConnectivityCheckRequestDestination +from ._models_py3 import ConnectivityCheckRequestProtocolConfiguration +from ._models_py3 import ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration +from ._models_py3 import ConnectivityCheckRequestSource +from ._models_py3 import ConnectivityCheckResponse +from ._models_py3 import ConnectivityHop +from ._models_py3 import ConnectivityIssue +from ._models_py3 import ConnectivityStatusContract +from ._models_py3 import ContentItemCollection +from ._models_py3 import ContentItemContract +from ._models_py3 import ContentTypeCollection +from ._models_py3 import ContentTypeContract +from ._models_py3 import DataMasking +from ._models_py3 import DataMaskingEntity +from ._models_py3 import DeletedServiceContract +from ._models_py3 import DeletedServicesCollection +from ._models_py3 import DeployConfigurationParameters +from ._models_py3 import DiagnosticCollection +from ._models_py3 import DiagnosticContract +from ._models_py3 import EmailTemplateCollection +from ._models_py3 import EmailTemplateContract +from ._models_py3 import EmailTemplateParametersContractProperties +from ._models_py3 import EmailTemplateUpdateParameters +from ._models_py3 import EndpointDependency +from ._models_py3 import EndpointDetail +from ._models_py3 import ErrorFieldContract +from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseBody +from ._models_py3 import GatewayCertificateAuthorityCollection +from ._models_py3 import GatewayCertificateAuthorityContract +from ._models_py3 import GatewayCollection +from ._models_py3 import GatewayContract +from ._models_py3 import GatewayHostnameConfigurationCollection +from ._models_py3 import GatewayHostnameConfigurationContract +from ._models_py3 import GatewayKeyRegenerationRequestContract +from ._models_py3 import GatewayKeysContract +from ._models_py3 import GatewayTokenContract +from ._models_py3 import GatewayTokenRequestContract +from ._models_py3 import GenerateSsoUrlResult +from ._models_py3 import GlobalSchemaCollection +from ._models_py3 import GlobalSchemaContract +from ._models_py3 import GroupCollection +from ._models_py3 import GroupContract +from ._models_py3 import GroupContractProperties +from ._models_py3 import GroupCreateParameters +from ._models_py3 import GroupUpdateParameters +from ._models_py3 import HTTPHeader +from ._models_py3 import HostnameConfiguration +from ._models_py3 import HttpMessageDiagnostic +from ._models_py3 import IdentityProviderBaseParameters +from ._models_py3 import IdentityProviderContract +from ._models_py3 import IdentityProviderContractProperties +from ._models_py3 import IdentityProviderCreateContract +from ._models_py3 import IdentityProviderCreateContractProperties +from ._models_py3 import IdentityProviderList +from ._models_py3 import IdentityProviderUpdateParameters +from ._models_py3 import IdentityProviderUpdateProperties +from ._models_py3 import IssueAttachmentCollection +from ._models_py3 import IssueAttachmentContract +from ._models_py3 import IssueCollection +from ._models_py3 import IssueCommentCollection +from ._models_py3 import IssueCommentContract +from ._models_py3 import IssueContract +from ._models_py3 import IssueContractBaseProperties +from ._models_py3 import IssueContractProperties +from ._models_py3 import IssueUpdateContract +from ._models_py3 import IssueUpdateContractProperties +from ._models_py3 import KeyVaultContractCreateProperties +from ._models_py3 import KeyVaultContractProperties +from ._models_py3 import KeyVaultLastAccessStatusContractProperties +from ._models_py3 import LoggerCollection +from ._models_py3 import LoggerContract +from ._models_py3 import LoggerUpdateContract +from ._models_py3 import NamedValueCollection +from ._models_py3 import NamedValueContract +from ._models_py3 import NamedValueContractProperties +from ._models_py3 import NamedValueCreateContract +from ._models_py3 import NamedValueCreateContractProperties +from ._models_py3 import NamedValueEntityBaseParameters +from ._models_py3 import NamedValueSecretContract +from ._models_py3 import NamedValueUpdateParameterProperties +from ._models_py3 import NamedValueUpdateParameters +from ._models_py3 import NetworkStatusContract +from ._models_py3 import NetworkStatusContractByLocation +from ._models_py3 import NotificationCollection +from ._models_py3 import NotificationContract +from ._models_py3 import OAuth2AuthenticationSettingsContract +from ._models_py3 import OpenIdAuthenticationSettingsContract +from ._models_py3 import OpenIdConnectProviderCollection +from ._models_py3 import OpenidConnectProviderContract +from ._models_py3 import OpenidConnectProviderUpdateContract +from ._models_py3 import Operation +from ._models_py3 import OperationCollection +from ._models_py3 import OperationContract +from ._models_py3 import OperationContractProperties +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationEntityBaseContract +from ._models_py3 import OperationListResult +from ._models_py3 import OperationResultContract +from ._models_py3 import OperationResultLogItemContract +from ._models_py3 import OperationTagResourceContractProperties +from ._models_py3 import OperationUpdateContract +from ._models_py3 import OperationUpdateContractProperties +from ._models_py3 import OutboundEnvironmentEndpoint +from ._models_py3 import OutboundEnvironmentEndpointList +from ._models_py3 import ParameterContract +from ._models_py3 import ParameterExampleContract +from ._models_py3 import PipelineDiagnosticSettings +from ._models_py3 import PolicyCollection +from ._models_py3 import PolicyContract +from ._models_py3 import PolicyDescriptionCollection +from ._models_py3 import PolicyDescriptionContract +from ._models_py3 import PortalDelegationSettings +from ._models_py3 import PortalRevisionCollection +from ._models_py3 import PortalRevisionContract +from ._models_py3 import PortalSettingValidationKeyContract +from ._models_py3 import PortalSettingsCollection +from ._models_py3 import PortalSettingsContract +from ._models_py3 import PortalSigninSettings +from ._models_py3 import PortalSignupSettings +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateEndpointConnectionRequest +from ._models_py3 import PrivateEndpointConnectionRequestProperties +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourceListResult +from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import ProductCollection +from ._models_py3 import ProductContract +from ._models_py3 import ProductContractProperties +from ._models_py3 import ProductEntityBaseParameters +from ._models_py3 import ProductTagResourceContractProperties +from ._models_py3 import ProductUpdateParameters +from ._models_py3 import ProductUpdateProperties +from ._models_py3 import QuotaCounterCollection +from ._models_py3 import QuotaCounterContract +from ._models_py3 import QuotaCounterValueContract +from ._models_py3 import QuotaCounterValueContractProperties +from ._models_py3 import QuotaCounterValueUpdateContract +from ._models_py3 import RecipientEmailCollection +from ._models_py3 import RecipientEmailContract +from ._models_py3 import RecipientUserCollection +from ._models_py3 import RecipientUserContract +from ._models_py3 import RecipientsContractProperties +from ._models_py3 import RegionContract +from ._models_py3 import RegionListResult +from ._models_py3 import RegistrationDelegationSettingsProperties +from ._models_py3 import RemotePrivateEndpointConnectionWrapper +from ._models_py3 import ReportCollection +from ._models_py3 import ReportRecordContract +from ._models_py3 import RepresentationContract +from ._models_py3 import RequestContract +from ._models_py3 import RequestReportCollection +from ._models_py3 import RequestReportRecordContract +from ._models_py3 import Resource +from ._models_py3 import ResourceLocationDataContract +from ._models_py3 import ResourceSku +from ._models_py3 import ResourceSkuCapacity +from ._models_py3 import ResourceSkuResult +from ._models_py3 import ResourceSkuResults +from ._models_py3 import ResponseContract +from ._models_py3 import SamplingSettings +from ._models_py3 import SaveConfigurationParameter +from ._models_py3 import SchemaCollection +from ._models_py3 import SchemaContract +from ._models_py3 import SubscriptionCollection +from ._models_py3 import SubscriptionContract +from ._models_py3 import SubscriptionCreateParameters +from ._models_py3 import SubscriptionKeyParameterNamesContract +from ._models_py3 import SubscriptionKeysContract +from ._models_py3 import SubscriptionUpdateParameters +from ._models_py3 import SubscriptionsDelegationSettingsProperties +from ._models_py3 import SystemData +from ._models_py3 import TagCollection +from ._models_py3 import TagContract +from ._models_py3 import TagCreateUpdateParameters +from ._models_py3 import TagDescriptionBaseProperties +from ._models_py3 import TagDescriptionCollection +from ._models_py3 import TagDescriptionContract +from ._models_py3 import TagDescriptionContractProperties +from ._models_py3 import TagDescriptionCreateParameters +from ._models_py3 import TagResourceCollection +from ._models_py3 import TagResourceContract +from ._models_py3 import TagResourceContractProperties +from ._models_py3 import TenantConfigurationSyncStateContract +from ._models_py3 import TenantSettingsCollection +from ._models_py3 import TenantSettingsContract +from ._models_py3 import TermsOfServiceProperties +from ._models_py3 import TokenBodyParameterContract +from ._models_py3 import UserCollection +from ._models_py3 import UserContract +from ._models_py3 import UserContractProperties +from ._models_py3 import UserCreateParameterProperties +from ._models_py3 import UserCreateParameters +from ._models_py3 import UserEntityBaseParameters +from ._models_py3 import UserIdentityCollection +from ._models_py3 import UserIdentityContract +from ._models_py3 import UserIdentityProperties +from ._models_py3 import UserTokenParameters +from ._models_py3 import UserTokenResult +from ._models_py3 import UserUpdateParameters +from ._models_py3 import UserUpdateParametersProperties +from ._models_py3 import VirtualNetworkConfiguration +from ._models_py3 import X509CertificateName + from ._api_management_client_enums import ( AccessIdName, + AccessType, AlwaysLog, ApiManagementSkuCapacityScaleType, ApiManagementSkuRestrictionsReasonCode, @@ -559,11 +321,16 @@ BearerTokenSendingMethod, BearerTokenSendingMethods, CertificateConfigurationStoreName, + CertificateSource, + CertificateStatus, ClientAuthenticationMethod, ConfigurationIdName, Confirmation, + ConnectionStatus, + ConnectivityCheckProtocol, ConnectivityStatusType, ContentFormat, + CreatedByType, DataMaskingMode, ExportApi, ExportFormat, @@ -573,21 +340,31 @@ 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, @@ -607,6 +384,7 @@ 'AccessInformationUpdateParameters', 'AdditionalLocation', 'ApiCollection', + 'ApiContactInformation', 'ApiContract', 'ApiContractProperties', 'ApiContractUpdateProperties', @@ -616,6 +394,7 @@ 'ApiEntityBaseContract', 'ApiExportResult', 'ApiExportResultValue', + 'ApiLicenseInformation', 'ApiManagementServiceApplyNetworkConfigurationParameters', 'ApiManagementServiceBackupRestoreParameters', 'ApiManagementServiceBaseProperties', @@ -655,6 +434,7 @@ 'ApiVersionSetUpdateParameters', 'ApiVersionSetUpdateParametersProperties', 'ApimResource', + 'ArmIdWrapper', 'AssociationContract', 'AuthenticationSettingsContract', 'AuthorizationServerCollection', @@ -687,6 +467,14 @@ 'CertificateCreateOrUpdateParameters', 'CertificateInformation', 'ClientSecretContract', + 'ConnectivityCheckRequest', + 'ConnectivityCheckRequestDestination', + 'ConnectivityCheckRequestProtocolConfiguration', + 'ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration', + 'ConnectivityCheckRequestSource', + 'ConnectivityCheckResponse', + 'ConnectivityHop', + 'ConnectivityIssue', 'ConnectivityStatusContract', 'ContentItemCollection', 'ContentItemContract', @@ -703,6 +491,8 @@ 'EmailTemplateContract', 'EmailTemplateParametersContractProperties', 'EmailTemplateUpdateParameters', + 'EndpointDependency', + 'EndpointDetail', 'ErrorFieldContract', 'ErrorResponse', 'ErrorResponseBody', @@ -717,11 +507,14 @@ 'GatewayTokenContract', 'GatewayTokenRequestContract', 'GenerateSsoUrlResult', + 'GlobalSchemaCollection', + 'GlobalSchemaContract', 'GroupCollection', 'GroupContract', 'GroupContractProperties', 'GroupCreateParameters', 'GroupUpdateParameters', + 'HTTPHeader', 'HostnameConfiguration', 'HttpMessageDiagnostic', 'IdentityProviderBaseParameters', @@ -778,7 +571,10 @@ 'OperationTagResourceContractProperties', 'OperationUpdateContract', 'OperationUpdateContractProperties', + 'OutboundEnvironmentEndpoint', + 'OutboundEnvironmentEndpointList', 'ParameterContract', + 'ParameterExampleContract', 'PipelineDiagnosticSettings', 'PolicyCollection', 'PolicyContract', @@ -792,6 +588,14 @@ 'PortalSettingsContract', 'PortalSigninSettings', 'PortalSignupSettings', + 'PrivateEndpoint', + 'PrivateEndpointConnection', + 'PrivateEndpointConnectionListResult', + 'PrivateEndpointConnectionRequest', + 'PrivateEndpointConnectionRequestProperties', + 'PrivateLinkResource', + 'PrivateLinkResourceListResult', + 'PrivateLinkServiceConnectionState', 'ProductCollection', 'ProductContract', 'ProductContractProperties', @@ -812,6 +616,7 @@ 'RegionContract', 'RegionListResult', 'RegistrationDelegationSettingsProperties', + 'RemotePrivateEndpointConnectionWrapper', 'ReportCollection', 'ReportRecordContract', 'RepresentationContract', @@ -836,6 +641,7 @@ 'SubscriptionKeysContract', 'SubscriptionUpdateParameters', 'SubscriptionsDelegationSettingsProperties', + 'SystemData', 'TagCollection', 'TagContract', 'TagCreateUpdateParameters', @@ -868,6 +674,7 @@ 'VirtualNetworkConfiguration', 'X509CertificateName', 'AccessIdName', + 'AccessType', 'AlwaysLog', 'ApiManagementSkuCapacityScaleType', 'ApiManagementSkuRestrictionsReasonCode', @@ -882,11 +689,16 @@ 'BearerTokenSendingMethod', 'BearerTokenSendingMethods', 'CertificateConfigurationStoreName', + 'CertificateSource', + 'CertificateStatus', 'ClientAuthenticationMethod', 'ConfigurationIdName', 'Confirmation', + 'ConnectionStatus', + 'ConnectivityCheckProtocol', 'ConnectivityStatusType', 'ContentFormat', + 'CreatedByType', 'DataMaskingMode', 'ExportApi', 'ExportFormat', @@ -896,21 +708,31 @@ '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', 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 796a886a4a179..b194dd14e5180 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 @@ -6,39 +6,35 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessIdName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessIdName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCESS = "access" GIT_ACCESS = "gitAccess" -class AlwaysLog(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of access to be used for the storage account. + """ + + #: Use access key. + ACCESS_KEY = "AccessKey" + #: Use system assigned managed identity. + SYSTEM_ASSIGNED_MANAGED_IDENTITY = "SystemAssignedManagedIdentity" + #: 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. """ #: Always log all erroneous request regardless of sampling settings. ALL_ERRORS = "allErrors" -class ApiManagementSkuCapacityScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ApiManagementSkuCapacityScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The scale type applicable to the sku. """ @@ -46,21 +42,21 @@ class ApiManagementSkuCapacityScaleType(with_metaclass(_CaseInsensitiveEnumMeta, MANUAL = "Manual" NONE = "None" -class ApiManagementSkuRestrictionsReasonCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ApiManagementSkuRestrictionsReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The reason for restriction. """ QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class ApiManagementSkuRestrictionsType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ApiManagementSkuRestrictionsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of restrictions. """ LOCATION = "Location" ZONE = "Zone" -class ApimIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ApimIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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. @@ -71,14 +67,16 @@ class ApimIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class ApiType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ApiType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of API. """ HTTP = "http" SOAP = "soap" + WEBSOCKET = "websocket" + GRAPHQL = "graphql" -class ApiVersionSetContractDetailsVersioningScheme(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ApiVersionSetContractDetailsVersioningScheme(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """An value that determines where the API Version identifier will be located in a HTTP request. """ @@ -86,14 +84,14 @@ class ApiVersionSetContractDetailsVersioningScheme(with_metaclass(_CaseInsensiti QUERY = "Query" HEADER = "Header" -class AppType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AppType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: 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)): +class AsyncOperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Status of an async operation. """ @@ -102,7 +100,7 @@ class AsyncOperationStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" FAILED = "Failed" -class AuthorizationMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AuthorizationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HEAD = "HEAD" OPTIONS = "OPTIONS" @@ -113,7 +111,7 @@ class AuthorizationMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PATCH = "PATCH" DELETE = "DELETE" -class BackendProtocol(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class BackendProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Backend communication protocol. """ @@ -122,12 +120,12 @@ class BackendProtocol(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The Backend is a SOAP service. SOAP = "soap" -class BearerTokenSendingMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class BearerTokenSendingMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTHORIZATION_HEADER = "authorizationHeader" QUERY = "query" -class BearerTokenSendingMethods(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class BearerTokenSendingMethods(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Form of an authorization grant, which the client uses to request the access token. """ @@ -136,7 +134,7 @@ class BearerTokenSendingMethods(with_metaclass(_CaseInsensitiveEnumMeta, str, En #: Access token will be transmitted as query parameters. QUERY = "query" -class CertificateConfigurationStoreName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CertificateConfigurationStoreName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The System.Security.Cryptography.x509certificates.StoreName certificate store location. Only Root and CertificateAuthority are valid locations. """ @@ -144,18 +142,35 @@ class CertificateConfigurationStoreName(with_metaclass(_CaseInsensitiveEnumMeta, CERTIFICATE_AUTHORITY = "CertificateAuthority" ROOT = "Root" -class ClientAuthenticationMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CertificateSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Certificate Source. + """ + + MANAGED = "Managed" + KEY_VAULT = "KeyVault" + CUSTOM = "Custom" + BUILT_IN = "BuiltIn" + +class CertificateStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Certificate Status. + """ + + COMPLETED = "Completed" + FAILED = "Failed" + IN_PROGRESS = "InProgress" + +class ClientAuthenticationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Basic Client Authentication method. BASIC = "Basic" #: Body based Authentication method. BODY = "Body" -class ConfigurationIdName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ConfigurationIdName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CONFIGURATION = "configuration" -class Confirmation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Confirmation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Determines the type of confirmation e-mail that will be sent to the newly created user. """ @@ -164,7 +179,25 @@ class Confirmation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Send an e-mail inviting the user to sign-up and complete registration. INVITE = "invite" -class ConnectivityStatusType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The connection status. + """ + + UNKNOWN = "Unknown" + CONNECTED = "Connected" + DISCONNECTED = "Disconnected" + DEGRADED = "Degraded" + +class ConnectivityCheckProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The request's protocol. Specific protocol configuration can be available based on this + selection. The specified destination address must be coherent with this value. + """ + + TCP = "TCP" + HTTP = "HTTP" + HTTPS = "HTTPS" + +class ConnectivityStatusType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Resource Connectivity Status Type identifier. """ @@ -172,7 +205,7 @@ class ConnectivityStatusType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum) SUCCESS = "success" FAILURE = "failure" -class ContentFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ContentFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Format of the Content in which the API is getting imported. """ @@ -196,8 +229,19 @@ class ContentFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): OPENAPI_LINK = "openapi-link" #: The OpenAPI 3.0 JSON document is hosted on a publicly accessible internet address. OPENAPI_JSON_LINK = "openapi+json-link" + #: 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. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" -class DataMaskingMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DataMaskingMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Data masking mode. """ @@ -206,11 +250,11 @@ class DataMaskingMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Hide the presence of an entity. HIDE = "Hide" -class ExportApi(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ExportApi(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TRUE = "true" -class ExportFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ExportFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Export the Api Definition in OpenAPI 2.0 Specification as JSON document to the Storage Blob. SWAGGER = "swagger-link" @@ -224,22 +268,22 @@ 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)): - """Format in which the Api Details are exported to the Storage Blob with Sas Key valid for 5 +class ExportResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Format in which the API Details are exported to the Storage Blob with Sas Key valid for 5 minutes. """ - #: The Api Definition is exported in OpenApi Specification 2.0 format to the Storage Blob. + #: 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 + #: The API Definition is exported in WSDL Schema to Storage Blob. This is only supported for APIs #: of Type ``soap``. WSDL = "wsdl-link+xml" - #: Export the Api Definition in WADL Schema to Storage Blob. + #: 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. + #: 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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Authorization Code Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.1. AUTHORIZATION_CODE = "authorizationCode" @@ -251,7 +295,7 @@ 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)): +class GroupType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Group type. """ @@ -259,7 +303,7 @@ class GroupType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SYSTEM = "system" EXTERNAL = "external" -class HostnameType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class HostnameType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Hostname type. """ @@ -269,7 +313,7 @@ class HostnameType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SCM = "Scm" DEVELOPER_PORTAL = "DeveloperPortal" -class HttpCorrelationProtocol(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class HttpCorrelationProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Sets correlation protocol to use for Application Insights diagnostics. """ @@ -281,7 +325,7 @@ 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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Facebook as Identity provider. FACEBOOK = "facebook" @@ -296,14 +340,28 @@ class IdentityProviderType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Azure Active Directory B2C as Identity provider. AAD_B2_C = "aadB2C" -class KeyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IssueType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of issue. + """ + + UNKNOWN = "Unknown" + AGENT_STOPPED = "AgentStopped" + GUEST_FIREWALL = "GuestFirewall" + DNS_RESOLUTION = "DnsResolution" + SOCKET_BIND = "SocketBind" + NETWORK_SECURITY_RULE = "NetworkSecurityRule" + USER_DEFINED_ROUTE = "UserDefinedRoute" + PORT_THROTTLED = "PortThrottled" + PLATFORM = "Platform" + +class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The Key to be used to generate token for user. """ PRIMARY = "primary" SECONDARY = "secondary" -class LoggerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class LoggerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Logger type. """ @@ -314,7 +372,14 @@ class LoggerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Azure Monitor. AZURE_MONITOR = "azureMonitor" -class NameAvailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Method(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The HTTP method to be used. + """ + + GET = "GET" + POST = "POST" + +class NameAvailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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. @@ -324,7 +389,7 @@ class NameAvailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum) INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class NotificationName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NotificationName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The following email recipients and users will receive email notifications about subscription #: requests for API products requiring approval. @@ -347,7 +412,7 @@ 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)): +class OperationNameFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The format of the Operation Name for Application Insights telemetries. Default is Name. """ @@ -356,7 +421,28 @@ class OperationNameFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: HTTP_VERB URL. URL = "Url" -class PolicyContentFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Origin(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The origin of the issue. + """ + + LOCAL = "Local" + INBOUND = "Inbound" + OUTBOUND = "Outbound" + +class PlatformVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Compute Platform Version running the service. + """ + + #: Platform version cannot be determined, as compute platform is not deployed. + UNDETERMINED = "undetermined" + #: Platform running the service on Single Tenant V1 platform. + STV1 = "stv1" + #: Platform running the service on Single Tenant V2 platform. + STV2 = "stv2" + #: Platform running the service on Multi Tenant V1 platform. + MTV1 = "mtv1" + +class PolicyContentFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Format of the policyContent. """ @@ -371,18 +457,18 @@ class PolicyContentFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Management service. RAWXML_LINK = "rawxml-link" -class PolicyExportFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyExportFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: 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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): POLICY = "policy" -class PolicyScopeContract(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PolicyScopeContract(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TENANT = "Tenant" PRODUCT = "Product" @@ -390,20 +476,43 @@ class PolicyScopeContract(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): OPERATION = "Operation" ALL = "All" -class PortalRevisionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Portal revision publishing status +class PortalRevisionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Status of the portal's revision. """ - #: Portal revision publishing is pending. + #: Portal's revision has been queued. PENDING = "pending" - #: Portal revision is publishing. + #: Portal's revision is being published. PUBLISHING = "publishing" - #: Portal revision publishing completed. + #: Portal's revision publishing completed. COMPLETED = "completed" - #: Portal revision publishing failed. + #: Portal's revision publishing failed. FAILED = "failed" -class ProductState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PreferredIPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """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. + """ + + SUCCEEDED = "Succeeded" + CREATING = "Creating" + DELETING = "Deleting" + FAILED = "Failed" + +class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The private endpoint connection status. + """ + + PENDING = "Pending" + APPROVED = "Approved" + REJECTED = "Rejected" + +class ProductState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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. @@ -412,12 +521,23 @@ class ProductState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): NOT_PUBLISHED = "notPublished" PUBLISHED = "published" -class Protocol(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Protocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HTTP = "http" HTTPS = "https" + WS = "ws" + WSS = "wss" + +class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """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' + """ + + ENABLED = "Enabled" + DISABLED = "Disabled" -class ResourceSkuCapacityScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceSkuCapacityScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The scale type applicable to the sku. """ @@ -428,18 +548,34 @@ class ResourceSkuCapacityScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, #: Scaling not supported. NONE = "none" -class SamplingType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SamplingType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Sampling type. """ #: Fixed-rate sampling. FIXED = "fixed" -class SettingsTypeName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SchemaType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Schema Type. Immutable. + """ + + #: Xml schema type. + XML = "xml" + #: Json schema type. + JSON = "json" + +class SettingsTypeName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PUBLIC = "public" -class SkuType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Severity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The severity of the issue. + """ + + ERROR = "Error" + WARNING = "Warning" + +class SkuType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Name of the Sku. """ @@ -456,20 +592,26 @@ class SkuType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Isolated SKU of Api Management. ISOLATED = "Isolated" -class SoapApiType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of Api to create. +class SoapApiType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Type of API to create. - * ``http`` creates a SOAP to REST API - * ``soap`` creates a SOAP pass-through API . + * ``http`` creates a REST API + * ``soap`` creates a SOAP pass-through API + * ``websocket`` creates websocket API + * ``graphql`` creates GraphQL API. """ #: Imports a SOAP API having a RESTful front end. SOAP_TO_REST = "http" - #: Imports the Soap API having a SOAP front end. + #: Imports the SOAP API having a SOAP front end. SOAP_PASS_THROUGH = "soap" + #: Imports the API having a Websocket front end. + WEB_SOCKET = "websocket" + #: Imports the API having a GraphQL front end. + GRAPH_QL = "graphql" -class State(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Status of the issue. """ @@ -484,7 +626,7 @@ class State(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: The issue was closed. CLOSED = "closed" -class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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 @@ -500,7 +642,7 @@ class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REJECTED = "rejected" CANCELLED = "cancelled" -class TemplateName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TemplateName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): APPLICATION_APPROVED_NOTIFICATION_MESSAGE = "applicationApprovedNotificationMessage" ACCOUNT_CLOSED_DEVELOPER = "accountClosedDeveloper" @@ -517,7 +659,7 @@ 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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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. """ @@ -531,7 +673,7 @@ 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)): +class Verbosity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The verbosity level applied to traces emitted by trace policies. """ @@ -545,7 +687,7 @@ class Verbosity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: diagnostic instance. ERROR = "error" -class VersioningScheme(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class VersioningScheme(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """An value that determines where the API Version identifier will be located in a HTTP request. """ @@ -556,7 +698,7 @@ 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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models.py deleted file mode 100644 index 57cd388224002..0000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models.py +++ /dev/null @@ -1,11933 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class AccessInformationCollection(msrest.serialization.Model): - """Paged AccessInformation list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.AccessInformationContract] - :param count: Total record count number across all pages. - :type count: long - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AccessInformationContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessInformationCollection, self).__init__(**kwargs) - self.value = None - self.count = kwargs.get('count', None) - self.next_link = None - - -class Resource(msrest.serialization.Model): - """The Resource definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class AccessInformationContract(Resource): - """Tenant Settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param id_properties_id: Access Information type ('access' or 'gitAccess'). - :type id_properties_id: str - :param principal_id: Principal (User) Identifier. - :type principal_id: str - :param enabled: Determines whether direct access is enabled. - :type enabled: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'id_properties_id': {'key': 'properties.id', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessInformationContract, self).__init__(**kwargs) - self.id_properties_id = kwargs.get('id_properties_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.enabled = kwargs.get('enabled', None) - - -class AccessInformationCreateParameters(msrest.serialization.Model): - """Tenant access information update parameters. - - :param principal_id: Principal (User) Identifier. - :type principal_id: str - :param primary_key: Primary access key. This property will not be filled on 'GET' operations! - Use '/listSecrets' POST request to get the value. - :type primary_key: str - :param secondary_key: Secondary access key. This property will not be filled on 'GET' - operations! Use '/listSecrets' POST request to get the value. - :type secondary_key: str - :param enabled: Determines whether direct access is enabled. - :type enabled: bool - """ - - _attribute_map = { - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'primary_key': {'key': 'properties.primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'properties.secondaryKey', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessInformationCreateParameters, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - self.enabled = kwargs.get('enabled', None) - - -class AccessInformationSecretsContract(msrest.serialization.Model): - """Tenant access information contract of the API Management service. - - :param id: Access Information type ('access' or 'gitAccess'). - :type id: str - :param principal_id: Principal (User) Identifier. - :type principal_id: str - :param primary_key: Primary access key. This property will not be filled on 'GET' operations! - Use '/listSecrets' POST request to get the value. - :type primary_key: str - :param secondary_key: Secondary access key. This property will not be filled on 'GET' - operations! Use '/listSecrets' POST request to get the value. - :type secondary_key: str - :param enabled: Determines whether direct access is enabled. - :type enabled: bool - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessInformationSecretsContract, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.principal_id = kwargs.get('principal_id', None) - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - self.enabled = kwargs.get('enabled', None) - - -class AccessInformationUpdateParameters(msrest.serialization.Model): - """Tenant access information update parameters. - - :param enabled: Determines whether direct access is enabled. - :type enabled: bool - """ - - _attribute_map = { - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessInformationUpdateParameters, self).__init__(**kwargs) - self.enabled = kwargs.get('enabled', None) - - -class AdditionalLocation(msrest.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. - - :param location: Required. The location name of the additional region among Azure Data center - regions. - :type location: str - :param sku: Required. SKU properties of the API Management service. - :type sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties - :param zones: A list of availability zones denoting where the resource needs to come from. - :type zones: list[str] - :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management - service in the additional location. Available only for Basic, Standard, Premium and Isolated - SKU. - :vartype public_ip_addresses: list[str] - :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management - service which is deployed in an Internal Virtual Network in a particular additional location. - Available only for Basic, Standard, Premium and Isolated SKU. - :vartype private_ip_addresses: list[str] - :param virtual_network_configuration: Virtual network configuration for the location. - :type virtual_network_configuration: - ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :ivar gateway_regional_url: Gateway URL of the API Management service in the Region. - :vartype gateway_regional_url: str - :param 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. - :type disable_gateway: bool - """ - - _validation = { - 'location': {'required': True}, - 'sku': {'required': True}, - 'public_ip_addresses': {'readonly': True}, - 'private_ip_addresses': {'readonly': True}, - 'gateway_regional_url': {'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]'}, - 'virtual_network_configuration': {'key': 'virtualNetworkConfiguration', 'type': 'VirtualNetworkConfiguration'}, - 'gateway_regional_url': {'key': 'gatewayRegionalUrl', 'type': 'str'}, - 'disable_gateway': {'key': 'disableGateway', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(AdditionalLocation, self).__init__(**kwargs) - self.location = kwargs['location'] - self.sku = kwargs['sku'] - self.zones = kwargs.get('zones', None) - self.public_ip_addresses = None - self.private_ip_addresses = None - self.virtual_network_configuration = kwargs.get('virtual_network_configuration', None) - self.gateway_regional_url = None - self.disable_gateway = kwargs.get('disable_gateway', False) - - -class ApiCollection(msrest.serialization.Model): - """Paged Api list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.ApiContract] - :param count: Total record count number across all pages. - :type count: long - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ApiContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiCollection, self).__init__(**kwargs) - self.value = None - self.count = kwargs.get('count', None) - self.next_link = None - - -class ApiContract(Resource): - """Api details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param description: Description of the API. May include HTML formatting tags. - :type description: str - :param authentication_settings: Collection of authentication settings included into this API. - :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made available. - :type subscription_key_parameter_names: - ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: "http", "soap". - :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is provided, default - revision 1 is created. - :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API is versioned. - :type api_version: str - :param is_current: Indicates if API revision is current api revision. - :type is_current: bool - :ivar is_online: Indicates if API revision is accessible via the gateway. - :vartype is_online: bool - :param api_revision_description: Description of the Api Revision. - :type api_revision_description: str - :param api_version_description: Description of the Api Version. - :type api_version_description: str - :param api_version_set_id: A resource identifier for the related ApiVersionSet. - :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product subscription is required for - accessing the API. - :type subscription_required: bool - :param source_api_id: API identifier of the source API. - :type source_api_id: str - :param display_name: API name. Must be 1 to 300 characters long. - :type display_name: str - :param service_url: Absolute URL of the backend service implementing this API. Cannot be more - than 2000 characters long. - :type service_url: str - :param 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. - :type path: str - :param protocols: Describes on which protocols the operations in this API can be invoked. - :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - :param api_version_set: Version set details. - :type 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'}, - '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__( - self, - **kwargs - ): - super(ApiContract, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.authentication_settings = kwargs.get('authentication_settings', None) - self.subscription_key_parameter_names = kwargs.get('subscription_key_parameter_names', None) - self.api_type = kwargs.get('api_type', None) - self.api_revision = kwargs.get('api_revision', None) - self.api_version = kwargs.get('api_version', None) - self.is_current = kwargs.get('is_current', None) - self.is_online = None - self.api_revision_description = kwargs.get('api_revision_description', None) - self.api_version_description = kwargs.get('api_version_description', None) - self.api_version_set_id = kwargs.get('api_version_set_id', None) - self.subscription_required = kwargs.get('subscription_required', None) - self.source_api_id = kwargs.get('source_api_id', None) - self.display_name = kwargs.get('display_name', None) - self.service_url = kwargs.get('service_url', None) - self.path = kwargs.get('path', None) - self.protocols = kwargs.get('protocols', None) - self.api_version_set = kwargs.get('api_version_set', None) - - -class ApiEntityBaseContract(msrest.serialization.Model): - """API base contract details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param description: Description of the API. May include HTML formatting tags. - :type description: str - :param authentication_settings: Collection of authentication settings included into this API. - :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made available. - :type subscription_key_parameter_names: - ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: "http", "soap". - :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is provided, default - revision 1 is created. - :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API is versioned. - :type api_version: str - :param is_current: Indicates if API revision is current api revision. - :type is_current: bool - :ivar is_online: Indicates if API revision is accessible via the gateway. - :vartype is_online: bool - :param api_revision_description: Description of the Api Revision. - :type api_revision_description: str - :param api_version_description: Description of the Api Version. - :type api_version_description: str - :param api_version_set_id: A resource identifier for the related ApiVersionSet. - :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product subscription is required for - accessing the API. - :type subscription_required: bool - """ - - _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'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiEntityBaseContract, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.authentication_settings = kwargs.get('authentication_settings', None) - self.subscription_key_parameter_names = kwargs.get('subscription_key_parameter_names', None) - self.api_type = kwargs.get('api_type', None) - self.api_revision = kwargs.get('api_revision', None) - self.api_version = kwargs.get('api_version', None) - self.is_current = kwargs.get('is_current', None) - self.is_online = None - self.api_revision_description = kwargs.get('api_revision_description', None) - self.api_version_description = kwargs.get('api_version_description', None) - self.api_version_set_id = kwargs.get('api_version_set_id', None) - self.subscription_required = kwargs.get('subscription_required', None) - - -class ApiContractProperties(ApiEntityBaseContract): - """Api Entity Properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param description: Description of the API. May include HTML formatting tags. - :type description: str - :param authentication_settings: Collection of authentication settings included into this API. - :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made available. - :type subscription_key_parameter_names: - ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: "http", "soap". - :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is provided, default - revision 1 is created. - :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API is versioned. - :type api_version: str - :param is_current: Indicates if API revision is current api revision. - :type is_current: bool - :ivar is_online: Indicates if API revision is accessible via the gateway. - :vartype is_online: bool - :param api_revision_description: Description of the Api Revision. - :type api_revision_description: str - :param api_version_description: Description of the Api Version. - :type api_version_description: str - :param api_version_set_id: A resource identifier for the related ApiVersionSet. - :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product subscription is required for - accessing the API. - :type subscription_required: bool - :param source_api_id: API identifier of the source API. - :type source_api_id: str - :param display_name: API name. Must be 1 to 300 characters long. - :type display_name: str - :param service_url: Absolute URL of the backend service implementing this API. Cannot be more - than 2000 characters long. - :type service_url: str - :param 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. - :type path: str - :param protocols: Describes on which protocols the operations in this API can be invoked. - :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - :param api_version_set: Version set details. - :type 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'}, - '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__( - self, - **kwargs - ): - super(ApiContractProperties, self).__init__(**kwargs) - self.source_api_id = kwargs.get('source_api_id', None) - self.display_name = kwargs.get('display_name', None) - self.service_url = kwargs.get('service_url', None) - self.path = kwargs['path'] - self.protocols = kwargs.get('protocols', None) - self.api_version_set = kwargs.get('api_version_set', None) - - -class ApiContractUpdateProperties(ApiEntityBaseContract): - """API update contract properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param description: Description of the API. May include HTML formatting tags. - :type description: str - :param authentication_settings: Collection of authentication settings included into this API. - :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made available. - :type subscription_key_parameter_names: - ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: "http", "soap". - :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is provided, default - revision 1 is created. - :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API is versioned. - :type api_version: str - :param is_current: Indicates if API revision is current api revision. - :type is_current: bool - :ivar is_online: Indicates if API revision is accessible via the gateway. - :vartype is_online: bool - :param api_revision_description: Description of the Api Revision. - :type api_revision_description: str - :param api_version_description: Description of the Api Version. - :type api_version_description: str - :param api_version_set_id: A resource identifier for the related ApiVersionSet. - :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product subscription is required for - accessing the API. - :type subscription_required: bool - :param display_name: API name. - :type display_name: str - :param service_url: Absolute URL of the backend service implementing this API. - :type service_url: str - :param 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. - :type path: str - :param protocols: Describes on which protocols the operations in this API can be invoked. - :type 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'}, - '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, - **kwargs - ): - super(ApiContractUpdateProperties, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.service_url = kwargs.get('service_url', None) - self.path = kwargs.get('path', None) - self.protocols = kwargs.get('protocols', None) - - -class ApiCreateOrUpdateParameter(msrest.serialization.Model): - """API Create or Update Parameters. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param description: Description of the API. May include HTML formatting tags. - :type description: str - :param authentication_settings: Collection of authentication settings included into this API. - :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made available. - :type subscription_key_parameter_names: - ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: "http", "soap". - :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is provided, default - revision 1 is created. - :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API is versioned. - :type api_version: str - :param is_current: Indicates if API revision is current api revision. - :type is_current: bool - :ivar is_online: Indicates if API revision is accessible via the gateway. - :vartype is_online: bool - :param api_revision_description: Description of the Api Revision. - :type api_revision_description: str - :param api_version_description: Description of the Api Version. - :type api_version_description: str - :param api_version_set_id: A resource identifier for the related ApiVersionSet. - :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product subscription is required for - accessing the API. - :type subscription_required: bool - :param source_api_id: API identifier of the source API. - :type source_api_id: str - :param display_name: API name. Must be 1 to 300 characters long. - :type display_name: str - :param service_url: Absolute URL of the backend service implementing this API. Cannot be more - than 2000 characters long. - :type service_url: str - :param 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. - :type path: str - :param protocols: Describes on which protocols the operations in this API can be invoked. - :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - :param api_version_set: Version set details. - :type api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails - :param value: Content value when Importing an API. - :type value: str - :param 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". - :type format: str or ~azure.mgmt.apimanagement.models.ContentFormat - :param wsdl_selector: Criteria to limit import of WSDL to a subset of the document. - :type wsdl_selector: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector - :param soap_api_type: Type of Api to create. - - - * ``http`` creates a SOAP to REST API - * ``soap`` creates a SOAP pass-through API . Possible values include: "http", "soap". - :type 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'}, - '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__( - self, - **kwargs - ): - super(ApiCreateOrUpdateParameter, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.authentication_settings = kwargs.get('authentication_settings', None) - self.subscription_key_parameter_names = kwargs.get('subscription_key_parameter_names', None) - self.api_type = kwargs.get('api_type', None) - self.api_revision = kwargs.get('api_revision', None) - self.api_version = kwargs.get('api_version', None) - self.is_current = kwargs.get('is_current', None) - self.is_online = None - self.api_revision_description = kwargs.get('api_revision_description', None) - self.api_version_description = kwargs.get('api_version_description', None) - self.api_version_set_id = kwargs.get('api_version_set_id', None) - self.subscription_required = kwargs.get('subscription_required', None) - self.source_api_id = kwargs.get('source_api_id', None) - self.display_name = kwargs.get('display_name', None) - self.service_url = kwargs.get('service_url', None) - self.path = kwargs.get('path', None) - self.protocols = kwargs.get('protocols', None) - self.api_version_set = kwargs.get('api_version_set', None) - self.value = kwargs.get('value', None) - self.format = kwargs.get('format', None) - self.wsdl_selector = kwargs.get('wsdl_selector', None) - self.soap_api_type = kwargs.get('soap_api_type', None) - - -class ApiCreateOrUpdateProperties(ApiContractProperties): - """Api Create or Update Properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param description: Description of the API. May include HTML formatting tags. - :type description: str - :param authentication_settings: Collection of authentication settings included into this API. - :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made available. - :type subscription_key_parameter_names: - ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: "http", "soap". - :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is provided, default - revision 1 is created. - :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API is versioned. - :type api_version: str - :param is_current: Indicates if API revision is current api revision. - :type is_current: bool - :ivar is_online: Indicates if API revision is accessible via the gateway. - :vartype is_online: bool - :param api_revision_description: Description of the Api Revision. - :type api_revision_description: str - :param api_version_description: Description of the Api Version. - :type api_version_description: str - :param api_version_set_id: A resource identifier for the related ApiVersionSet. - :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product subscription is required for - accessing the API. - :type subscription_required: bool - :param source_api_id: API identifier of the source API. - :type source_api_id: str - :param display_name: API name. Must be 1 to 300 characters long. - :type display_name: str - :param service_url: Absolute URL of the backend service implementing this API. Cannot be more - than 2000 characters long. - :type service_url: str - :param 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. - :type path: str - :param protocols: Describes on which protocols the operations in this API can be invoked. - :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - :param api_version_set: Version set details. - :type api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails - :param value: Content value when Importing an API. - :type value: str - :param 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". - :type format: str or ~azure.mgmt.apimanagement.models.ContentFormat - :param wsdl_selector: Criteria to limit import of WSDL to a subset of the document. - :type wsdl_selector: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector - :param soap_api_type: Type of Api to create. - - - * ``http`` creates a SOAP to REST API - * ``soap`` creates a SOAP pass-through API . Possible values include: "http", "soap". - :type 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'}, - '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__( - self, - **kwargs - ): - super(ApiCreateOrUpdateProperties, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.format = kwargs.get('format', None) - self.wsdl_selector = kwargs.get('wsdl_selector', None) - self.soap_api_type = kwargs.get('soap_api_type', None) - - -class ApiCreateOrUpdatePropertiesWsdlSelector(msrest.serialization.Model): - """Criteria to limit import of WSDL to a subset of the document. - - :param wsdl_service_name: Name of service to import from WSDL. - :type wsdl_service_name: str - :param wsdl_endpoint_name: Name of endpoint(port) to import from WSDL. - :type wsdl_endpoint_name: str - """ - - _attribute_map = { - 'wsdl_service_name': {'key': 'wsdlServiceName', 'type': 'str'}, - 'wsdl_endpoint_name': {'key': 'wsdlEndpointName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiCreateOrUpdatePropertiesWsdlSelector, self).__init__(**kwargs) - self.wsdl_service_name = kwargs.get('wsdl_service_name', None) - self.wsdl_endpoint_name = kwargs.get('wsdl_endpoint_name', None) - - -class ApiExportResult(msrest.serialization.Model): - """API Export result. - - :param id: ResourceId of the API which was exported. - :type id: str - :param 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". - :type export_result_format: str or ~azure.mgmt.apimanagement.models.ExportResultFormat - :param value: The object defining the schema of the exported Api Detail. - :type value: ~azure.mgmt.apimanagement.models.ApiExportResultValue - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'export_result_format': {'key': 'format', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'ApiExportResultValue'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiExportResult, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.export_result_format = kwargs.get('export_result_format', None) - self.value = kwargs.get('value', None) - - -class ApiExportResultValue(msrest.serialization.Model): - """The object defining the schema of the exported Api Detail. - - :param link: Link to the Storage Blob containing the result of the export operation. The Blob - Uri is only valid for 5 minutes. - :type link: str - """ - - _attribute_map = { - 'link': {'key': 'link', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiExportResultValue, self).__init__(**kwargs) - self.link = kwargs.get('link', None) - - -class ApiManagementServiceApplyNetworkConfigurationParameters(msrest.serialization.Model): - """Parameter supplied to the Apply Network configuration operation. - - :param 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. - :type location: str - """ - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementServiceApplyNetworkConfigurationParameters, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - - -class ApiManagementServiceBackupRestoreParameters(msrest.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. - - :param storage_account: Required. Azure Cloud Storage account (used to place/retrieve the - backup) name. - :type storage_account: str - :param access_key: Required. Azure Cloud Storage account (used to place/retrieve the backup) - access key. - :type access_key: str - :param container_name: Required. Azure Cloud Storage blob container name used to place/retrieve - the backup. - :type container_name: str - :param backup_name: Required. The name of the backup file to create. - :type backup_name: str - """ - - _validation = { - 'storage_account': {'required': True}, - 'access_key': {'required': True}, - 'container_name': {'required': True}, - 'backup_name': {'required': True}, - } - - _attribute_map = { - 'storage_account': {'key': 'storageAccount', 'type': 'str'}, - 'access_key': {'key': 'accessKey', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'backup_name': {'key': 'backupName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementServiceBackupRestoreParameters, self).__init__(**kwargs) - self.storage_account = kwargs['storage_account'] - self.access_key = kwargs['access_key'] - self.container_name = kwargs['container_name'] - self.backup_name = kwargs['backup_name'] - - -class ApiManagementServiceBaseProperties(msrest.serialization.Model): - """Base Properties of an API Management service resource description. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param notification_sender_email: Email address from which the notification will be sent. - :type notification_sender_email: str - :ivar provisioning_state: The current provisioning state of the API Management service which - can be one of the following: - Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. - :vartype provisioning_state: str - :ivar target_provisioning_state: The provisioning state of the API Management service, which is - targeted by the long running operation started on the service. - :vartype target_provisioning_state: str - :ivar created_at_utc: Creation UTC date of the API Management service.The date conforms to the - following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype created_at_utc: ~datetime.datetime - :ivar gateway_url: Gateway URL of the API Management service. - :vartype gateway_url: str - :ivar gateway_regional_url: Gateway URL of the API Management service in the Default Region. - :vartype gateway_regional_url: str - :ivar portal_url: Publisher portal endpoint Url of the API Management service. - :vartype portal_url: str - :ivar management_api_url: Management API endpoint URL of the API Management service. - :vartype management_api_url: str - :ivar scm_url: SCM endpoint URL of the API Management service. - :vartype scm_url: str - :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. - :vartype developer_portal_url: str - :param hostname_configurations: Custom hostname configuration of the API Management service. - :type hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] - :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management - service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. - :vartype public_ip_addresses: list[str] - :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management - service in Primary region which is deployed in an Internal Virtual Network. Available only for - Basic, Standard, Premium and Isolated SKU. - :vartype private_ip_addresses: list[str] - :param virtual_network_configuration: Virtual network configuration of the API Management - service. - :type virtual_network_configuration: - ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :param additional_locations: Additional datacenter locations of the API Management service. - :type additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :param custom_properties: Custom properties of the API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the - cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to - disable just TLS 1.1.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to - disable TLS 1.0 on an API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used - to disable just TLS 1.1 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used - to disable TLS 1.0 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable - HTTP2 protocol on an API Management service.
Not specifying any of these properties on - PATCH operation will reset omitted properties' values to their defaults. For all the settings - except Http2 the default value is ``True`` if the service was created on or before April 1st - 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can - disable any of next ciphers by using settings - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: - TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, - TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. - For example, - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ - ``false``. The default value is ``true`` for them. Note: next ciphers can't be disabled since - they are required by Azure CloudService internal components: - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384. - :type custom_properties: dict[str, str] - :param certificates: List of Certificates that need to be installed in the API Management - service. Max supported certificates that can be installed is 10. - :type certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :param 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. - :type enable_client_certificate: bool - :param disable_gateway: Property only valid for an Api Management service deployed in multiple - locations. This can be used to disable the gateway in master region. - :type disable_gateway: bool - :param virtual_network_type: The type of VPN in which API Management service needs to be - configured in. None (Default Value) means the API Management service is not part of any Virtual - Network, External means the API Management deployment is set up inside a Virtual Network having - an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside - a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", - "External", "Internal". Default value: "None". - :type virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :param api_version_constraint: Control Plane Apis version constraint for the API Management - service. - :type api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :param 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. - :type restore: bool - """ - - _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}, - } - - _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]'}, - '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'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementServiceBaseProperties, self).__init__(**kwargs) - self.notification_sender_email = kwargs.get('notification_sender_email', None) - self.provisioning_state = None - self.target_provisioning_state = None - self.created_at_utc = None - self.gateway_url = None - self.gateway_regional_url = None - self.portal_url = None - self.management_api_url = None - self.scm_url = None - self.developer_portal_url = None - self.hostname_configurations = kwargs.get('hostname_configurations', None) - self.public_ip_addresses = None - self.private_ip_addresses = None - self.virtual_network_configuration = kwargs.get('virtual_network_configuration', None) - self.additional_locations = kwargs.get('additional_locations', None) - self.custom_properties = kwargs.get('custom_properties', None) - self.certificates = kwargs.get('certificates', None) - self.enable_client_certificate = kwargs.get('enable_client_certificate', False) - self.disable_gateway = kwargs.get('disable_gateway', False) - self.virtual_network_type = kwargs.get('virtual_network_type', "None") - self.api_version_constraint = kwargs.get('api_version_constraint', None) - self.restore = kwargs.get('restore', False) - - -class ApiManagementServiceCheckNameAvailabilityParameters(msrest.serialization.Model): - """Parameters supplied to the CheckNameAvailability operation. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name to check for availability. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementServiceCheckNameAvailabilityParameters, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class ApiManagementServiceGetDomainOwnershipIdentifierResult(msrest.serialization.Model): - """Response of the GetDomainOwnershipIdentifier operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar domain_ownership_identifier: The domain ownership identifier value. - :vartype domain_ownership_identifier: str - """ - - _validation = { - 'domain_ownership_identifier': {'readonly': True}, - } - - _attribute_map = { - 'domain_ownership_identifier': {'key': 'domainOwnershipIdentifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementServiceGetDomainOwnershipIdentifierResult, self).__init__(**kwargs) - self.domain_ownership_identifier = None - - -class ApiManagementServiceGetSsoTokenResult(msrest.serialization.Model): - """The response of the GetSsoToken operation. - - :param redirect_uri: Redirect URL to the Publisher Portal containing the SSO token. - :type redirect_uri: str - """ - - _attribute_map = { - 'redirect_uri': {'key': 'redirectUri', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementServiceGetSsoTokenResult, self).__init__(**kwargs) - self.redirect_uri = kwargs.get('redirect_uri', None) - - -class ApiManagementServiceIdentity(msrest.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. - - :param 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". - :type type: str or ~azure.mgmt.apimanagement.models.ApimIdentityType - :ivar principal_id: The principal id of the identity. - :vartype principal_id: str - :ivar tenant_id: The client tenant id of the identity. - :vartype tenant_id: str - :param 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}'. - :type user_assigned_identities: dict[str, - ~azure.mgmt.apimanagement.models.UserIdentityProperties] - """ - - _validation = { - 'type': {'required': True}, - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserIdentityProperties}'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementServiceIdentity, self).__init__(**kwargs) - self.type = kwargs['type'] - self.principal_id = None - self.tenant_id = None - self.user_assigned_identities = kwargs.get('user_assigned_identities', None) - - -class ApiManagementServiceListResult(msrest.serialization.Model): - """The response of the List API Management services operation. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. Result of the List API Management services operation. - :type value: list[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of API Management services. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ApiManagementServiceResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementServiceListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class ApiManagementServiceNameAvailabilityResult(msrest.serialization.Model): - """Response of the CheckNameAvailability operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name_available: True if the name is available and can be used to create a new API - Management service; otherwise false. - :vartype name_available: bool - :ivar message: If reason == invalid, provide the user with the reason why the given name is - invalid, and provide the resource naming requirements so that the user can select a valid name. - If reason == AlreadyExists, explain that :code:`` is already in use, and direct - them to select a different name. - :vartype message: str - :param 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". - :type reason: str or ~azure.mgmt.apimanagement.models.NameAvailabilityReason - """ - - _validation = { - 'name_available': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'message': {'key': 'message', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementServiceNameAvailabilityResult, self).__init__(**kwargs) - self.name_available = None - self.message = None - self.reason = kwargs.get('reason', None) - - -class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): - """Properties of an API Management service resource description. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param notification_sender_email: Email address from which the notification will be sent. - :type notification_sender_email: str - :ivar provisioning_state: The current provisioning state of the API Management service which - can be one of the following: - Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. - :vartype provisioning_state: str - :ivar target_provisioning_state: The provisioning state of the API Management service, which is - targeted by the long running operation started on the service. - :vartype target_provisioning_state: str - :ivar created_at_utc: Creation UTC date of the API Management service.The date conforms to the - following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype created_at_utc: ~datetime.datetime - :ivar gateway_url: Gateway URL of the API Management service. - :vartype gateway_url: str - :ivar gateway_regional_url: Gateway URL of the API Management service in the Default Region. - :vartype gateway_regional_url: str - :ivar portal_url: Publisher portal endpoint Url of the API Management service. - :vartype portal_url: str - :ivar management_api_url: Management API endpoint URL of the API Management service. - :vartype management_api_url: str - :ivar scm_url: SCM endpoint URL of the API Management service. - :vartype scm_url: str - :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. - :vartype developer_portal_url: str - :param hostname_configurations: Custom hostname configuration of the API Management service. - :type hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] - :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management - service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. - :vartype public_ip_addresses: list[str] - :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management - service in Primary region which is deployed in an Internal Virtual Network. Available only for - Basic, Standard, Premium and Isolated SKU. - :vartype private_ip_addresses: list[str] - :param virtual_network_configuration: Virtual network configuration of the API Management - service. - :type virtual_network_configuration: - ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :param additional_locations: Additional datacenter locations of the API Management service. - :type additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :param custom_properties: Custom properties of the API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the - cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to - disable just TLS 1.1.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to - disable TLS 1.0 on an API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used - to disable just TLS 1.1 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used - to disable TLS 1.0 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable - HTTP2 protocol on an API Management service.
Not specifying any of these properties on - PATCH operation will reset omitted properties' values to their defaults. For all the settings - except Http2 the default value is ``True`` if the service was created on or before April 1st - 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can - disable any of next ciphers by using settings - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: - TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, - TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. - For example, - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ - ``false``. The default value is ``true`` for them. Note: next ciphers can't be disabled since - they are required by Azure CloudService internal components: - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384. - :type custom_properties: dict[str, str] - :param certificates: List of Certificates that need to be installed in the API Management - service. Max supported certificates that can be installed is 10. - :type certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :param 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. - :type enable_client_certificate: bool - :param disable_gateway: Property only valid for an Api Management service deployed in multiple - locations. This can be used to disable the gateway in master region. - :type disable_gateway: bool - :param virtual_network_type: The type of VPN in which API Management service needs to be - configured in. None (Default Value) means the API Management service is not part of any Virtual - Network, External means the API Management deployment is set up inside a Virtual Network having - an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside - a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", - "External", "Internal". Default value: "None". - :type virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :param api_version_constraint: Control Plane Apis version constraint for the API Management - service. - :type api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :param 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. - :type restore: bool - :param publisher_email: Required. Publisher email. - :type publisher_email: str - :param publisher_name: Required. Publisher name. - :type 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}, - '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]'}, - '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'}, - 'publisher_email': {'key': 'publisherEmail', 'type': 'str'}, - 'publisher_name': {'key': 'publisherName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementServiceProperties, self).__init__(**kwargs) - self.publisher_email = kwargs['publisher_email'] - self.publisher_name = kwargs['publisher_name'] - - -class ApimResource(msrest.serialization.Model): - """The Resource definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource is set to Microsoft.ApiManagement. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ApimResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.tags = kwargs.get('tags', None) - - -class ApiManagementServiceResource(ApimResource): - """A single API Management service resource in List or Get response. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource is set to Microsoft.ApiManagement. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Required. SKU properties of the API Management service. - :type sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties - :param identity: Managed service identity of the Api Management service. - :type identity: ~azure.mgmt.apimanagement.models.ApiManagementServiceIdentity - :param location: Required. Resource location. - :type location: str - :ivar etag: ETag of the resource. - :vartype etag: str - :param zones: A list of availability zones denoting where the resource needs to come from. - :type zones: list[str] - :param notification_sender_email: Email address from which the notification will be sent. - :type notification_sender_email: str - :ivar provisioning_state: The current provisioning state of the API Management service which - can be one of the following: - Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. - :vartype provisioning_state: str - :ivar target_provisioning_state: The provisioning state of the API Management service, which is - targeted by the long running operation started on the service. - :vartype target_provisioning_state: str - :ivar created_at_utc: Creation UTC date of the API Management service.The date conforms to the - following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype created_at_utc: ~datetime.datetime - :ivar gateway_url: Gateway URL of the API Management service. - :vartype gateway_url: str - :ivar gateway_regional_url: Gateway URL of the API Management service in the Default Region. - :vartype gateway_regional_url: str - :ivar portal_url: Publisher portal endpoint Url of the API Management service. - :vartype portal_url: str - :ivar management_api_url: Management API endpoint URL of the API Management service. - :vartype management_api_url: str - :ivar scm_url: SCM endpoint URL of the API Management service. - :vartype scm_url: str - :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. - :vartype developer_portal_url: str - :param hostname_configurations: Custom hostname configuration of the API Management service. - :type hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] - :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management - service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. - :vartype public_ip_addresses: list[str] - :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management - service in Primary region which is deployed in an Internal Virtual Network. Available only for - Basic, Standard, Premium and Isolated SKU. - :vartype private_ip_addresses: list[str] - :param virtual_network_configuration: Virtual network configuration of the API Management - service. - :type virtual_network_configuration: - ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :param additional_locations: Additional datacenter locations of the API Management service. - :type additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :param custom_properties: Custom properties of the API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the - cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to - disable just TLS 1.1.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to - disable TLS 1.0 on an API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used - to disable just TLS 1.1 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used - to disable TLS 1.0 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable - HTTP2 protocol on an API Management service.
Not specifying any of these properties on - PATCH operation will reset omitted properties' values to their defaults. For all the settings - except Http2 the default value is ``True`` if the service was created on or before April 1st - 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can - disable any of next ciphers by using settings - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: - TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, - TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. - For example, - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ - ``false``. The default value is ``true`` for them. Note: next ciphers can't be disabled since - they are required by Azure CloudService internal components: - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384. - :type custom_properties: dict[str, str] - :param certificates: List of Certificates that need to be installed in the API Management - service. Max supported certificates that can be installed is 10. - :type certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :param 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. - :type enable_client_certificate: bool - :param disable_gateway: Property only valid for an Api Management service deployed in multiple - locations. This can be used to disable the gateway in master region. - :type disable_gateway: bool - :param virtual_network_type: The type of VPN in which API Management service needs to be - configured in. None (Default Value) means the API Management service is not part of any Virtual - Network, External means the API Management deployment is set up inside a Virtual Network having - an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside - a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", - "External", "Internal". Default value: "None". - :type virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :param api_version_constraint: Control Plane Apis version constraint for the API Management - service. - :type api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :param 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. - :type restore: bool - :param publisher_email: Required. Publisher email. - :type publisher_email: str - :param publisher_name: Required. Publisher name. - :type publisher_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'required': 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}, - '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'}, - '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]'}, - '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'}, - 'publisher_email': {'key': 'properties.publisherEmail', 'type': 'str'}, - 'publisher_name': {'key': 'properties.publisherName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementServiceResource, self).__init__(**kwargs) - self.sku = kwargs['sku'] - self.identity = kwargs.get('identity', None) - self.location = kwargs['location'] - self.etag = None - self.zones = kwargs.get('zones', None) - self.notification_sender_email = kwargs.get('notification_sender_email', None) - self.provisioning_state = None - self.target_provisioning_state = None - self.created_at_utc = None - self.gateway_url = None - self.gateway_regional_url = None - self.portal_url = None - self.management_api_url = None - self.scm_url = None - self.developer_portal_url = None - self.hostname_configurations = kwargs.get('hostname_configurations', None) - self.public_ip_addresses = None - self.private_ip_addresses = None - self.virtual_network_configuration = kwargs.get('virtual_network_configuration', None) - self.additional_locations = kwargs.get('additional_locations', None) - self.custom_properties = kwargs.get('custom_properties', None) - self.certificates = kwargs.get('certificates', None) - self.enable_client_certificate = kwargs.get('enable_client_certificate', False) - self.disable_gateway = kwargs.get('disable_gateway', False) - self.virtual_network_type = kwargs.get('virtual_network_type', "None") - self.api_version_constraint = kwargs.get('api_version_constraint', None) - self.restore = kwargs.get('restore', False) - self.publisher_email = kwargs['publisher_email'] - self.publisher_name = kwargs['publisher_name'] - - -class ApiManagementServiceSkuProperties(msrest.serialization.Model): - """API Management service resource SKU properties. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Name of the Sku. Possible values include: "Developer", "Standard", - "Premium", "Basic", "Consumption", "Isolated". - :type name: str or ~azure.mgmt.apimanagement.models.SkuType - :param capacity: Required. Capacity of the SKU (number of deployed units of the SKU). For - Consumption SKU capacity must be specified as 0. - :type capacity: int - """ - - _validation = { - 'name': {'required': True}, - 'capacity': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementServiceSkuProperties, self).__init__(**kwargs) - self.name = kwargs['name'] - self.capacity = kwargs['capacity'] - - -class ApiManagementServiceUpdateParameters(ApimResource): - """Parameter supplied to Update Api Management Service. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource is set to Microsoft.ApiManagement. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: SKU properties of the API Management service. - :type sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties - :param identity: Managed service identity of the Api Management service. - :type identity: ~azure.mgmt.apimanagement.models.ApiManagementServiceIdentity - :ivar etag: ETag of the resource. - :vartype etag: str - :param notification_sender_email: Email address from which the notification will be sent. - :type notification_sender_email: str - :ivar provisioning_state: The current provisioning state of the API Management service which - can be one of the following: - Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. - :vartype provisioning_state: str - :ivar target_provisioning_state: The provisioning state of the API Management service, which is - targeted by the long running operation started on the service. - :vartype target_provisioning_state: str - :ivar created_at_utc: Creation UTC date of the API Management service.The date conforms to the - following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype created_at_utc: ~datetime.datetime - :ivar gateway_url: Gateway URL of the API Management service. - :vartype gateway_url: str - :ivar gateway_regional_url: Gateway URL of the API Management service in the Default Region. - :vartype gateway_regional_url: str - :ivar portal_url: Publisher portal endpoint Url of the API Management service. - :vartype portal_url: str - :ivar management_api_url: Management API endpoint URL of the API Management service. - :vartype management_api_url: str - :ivar scm_url: SCM endpoint URL of the API Management service. - :vartype scm_url: str - :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. - :vartype developer_portal_url: str - :param hostname_configurations: Custom hostname configuration of the API Management service. - :type hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] - :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management - service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. - :vartype public_ip_addresses: list[str] - :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management - service in Primary region which is deployed in an Internal Virtual Network. Available only for - Basic, Standard, Premium and Isolated SKU. - :vartype private_ip_addresses: list[str] - :param virtual_network_configuration: Virtual network configuration of the API Management - service. - :type virtual_network_configuration: - ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :param additional_locations: Additional datacenter locations of the API Management service. - :type additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :param custom_properties: Custom properties of the API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the - cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to - disable just TLS 1.1.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to - disable TLS 1.0 on an API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used - to disable just TLS 1.1 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used - to disable TLS 1.0 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable - HTTP2 protocol on an API Management service.
Not specifying any of these properties on - PATCH operation will reset omitted properties' values to their defaults. For all the settings - except Http2 the default value is ``True`` if the service was created on or before April 1st - 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can - disable any of next ciphers by using settings - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: - TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, - TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. - For example, - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ - ``false``. The default value is ``true`` for them. Note: next ciphers can't be disabled since - they are required by Azure CloudService internal components: - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384. - :type custom_properties: dict[str, str] - :param certificates: List of Certificates that need to be installed in the API Management - service. Max supported certificates that can be installed is 10. - :type certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :param 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. - :type enable_client_certificate: bool - :param disable_gateway: Property only valid for an Api Management service deployed in multiple - locations. This can be used to disable the gateway in master region. - :type disable_gateway: bool - :param virtual_network_type: The type of VPN in which API Management service needs to be - configured in. None (Default Value) means the API Management service is not part of any Virtual - Network, External means the API Management deployment is set up inside a Virtual Network having - an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside - a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", - "External", "Internal". Default value: "None". - :type virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :param api_version_constraint: Control Plane Apis version constraint for the API Management - service. - :type api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :param 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. - :type restore: bool - :param publisher_email: Publisher email. - :type publisher_email: str - :param publisher_name: Publisher name. - :type publisher_name: str - """ - - _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}, - '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'}, - '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]'}, - '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'}, - 'publisher_email': {'key': 'properties.publisherEmail', 'type': 'str'}, - 'publisher_name': {'key': 'properties.publisherName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementServiceUpdateParameters, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.identity = kwargs.get('identity', None) - self.etag = None - self.notification_sender_email = kwargs.get('notification_sender_email', None) - self.provisioning_state = None - self.target_provisioning_state = None - self.created_at_utc = None - self.gateway_url = None - self.gateway_regional_url = None - self.portal_url = None - self.management_api_url = None - self.scm_url = None - self.developer_portal_url = None - self.hostname_configurations = kwargs.get('hostname_configurations', None) - self.public_ip_addresses = None - self.private_ip_addresses = None - self.virtual_network_configuration = kwargs.get('virtual_network_configuration', None) - self.additional_locations = kwargs.get('additional_locations', None) - self.custom_properties = kwargs.get('custom_properties', None) - self.certificates = kwargs.get('certificates', None) - self.enable_client_certificate = kwargs.get('enable_client_certificate', False) - self.disable_gateway = kwargs.get('disable_gateway', False) - self.virtual_network_type = kwargs.get('virtual_network_type', "None") - self.api_version_constraint = kwargs.get('api_version_constraint', None) - self.restore = kwargs.get('restore', False) - self.publisher_email = kwargs.get('publisher_email', None) - self.publisher_name = kwargs.get('publisher_name', None) - - -class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): - """Properties of an API Management service resource description. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param notification_sender_email: Email address from which the notification will be sent. - :type notification_sender_email: str - :ivar provisioning_state: The current provisioning state of the API Management service which - can be one of the following: - Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. - :vartype provisioning_state: str - :ivar target_provisioning_state: The provisioning state of the API Management service, which is - targeted by the long running operation started on the service. - :vartype target_provisioning_state: str - :ivar created_at_utc: Creation UTC date of the API Management service.The date conforms to the - following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype created_at_utc: ~datetime.datetime - :ivar gateway_url: Gateway URL of the API Management service. - :vartype gateway_url: str - :ivar gateway_regional_url: Gateway URL of the API Management service in the Default Region. - :vartype gateway_regional_url: str - :ivar portal_url: Publisher portal endpoint Url of the API Management service. - :vartype portal_url: str - :ivar management_api_url: Management API endpoint URL of the API Management service. - :vartype management_api_url: str - :ivar scm_url: SCM endpoint URL of the API Management service. - :vartype scm_url: str - :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. - :vartype developer_portal_url: str - :param hostname_configurations: Custom hostname configuration of the API Management service. - :type hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] - :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management - service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. - :vartype public_ip_addresses: list[str] - :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management - service in Primary region which is deployed in an Internal Virtual Network. Available only for - Basic, Standard, Premium and Isolated SKU. - :vartype private_ip_addresses: list[str] - :param virtual_network_configuration: Virtual network configuration of the API Management - service. - :type virtual_network_configuration: - ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :param additional_locations: Additional datacenter locations of the API Management service. - :type additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :param custom_properties: Custom properties of the API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the - cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to - disable just TLS 1.1.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to - disable TLS 1.0 on an API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used - to disable just TLS 1.1 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used - to disable TLS 1.0 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable - HTTP2 protocol on an API Management service.
Not specifying any of these properties on - PATCH operation will reset omitted properties' values to their defaults. For all the settings - except Http2 the default value is ``True`` if the service was created on or before April 1st - 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can - disable any of next ciphers by using settings - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: - TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, - TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. - For example, - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ - ``false``. The default value is ``true`` for them. Note: next ciphers can't be disabled since - they are required by Azure CloudService internal components: - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384. - :type custom_properties: dict[str, str] - :param certificates: List of Certificates that need to be installed in the API Management - service. Max supported certificates that can be installed is 10. - :type certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :param 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. - :type enable_client_certificate: bool - :param disable_gateway: Property only valid for an Api Management service deployed in multiple - locations. This can be used to disable the gateway in master region. - :type disable_gateway: bool - :param virtual_network_type: The type of VPN in which API Management service needs to be - configured in. None (Default Value) means the API Management service is not part of any Virtual - Network, External means the API Management deployment is set up inside a Virtual Network having - an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside - a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", - "External", "Internal". Default value: "None". - :type virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :param api_version_constraint: Control Plane Apis version constraint for the API Management - service. - :type api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :param 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. - :type restore: bool - :param publisher_email: Publisher email. - :type publisher_email: str - :param publisher_name: Publisher name. - :type 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}, - '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]'}, - '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'}, - 'publisher_email': {'key': 'publisherEmail', 'type': 'str'}, - 'publisher_name': {'key': 'publisherName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementServiceUpdateProperties, self).__init__(**kwargs) - self.publisher_email = kwargs.get('publisher_email', None) - self.publisher_name = kwargs.get('publisher_name', None) - - -class ApiManagementSku(msrest.serialization.Model): - """Describes an available ApiManagement SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of resource the SKU applies to. - :vartype resource_type: str - :ivar name: The name of SKU. - :vartype name: str - :ivar tier: Specifies the tier of virtual machines in a scale set.:code:`
`:code:`
` - Possible Values::code:`
`:code:`
` **Standard**\ :code:`
`:code:`
` - **Basic**. - :vartype tier: str - :ivar size: The Size of the SKU. - :vartype size: str - :ivar family: The Family of this particular SKU. - :vartype family: str - :ivar kind: The Kind of resources that are supported in this SKU. - :vartype kind: str - :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: ~azure.mgmt.apimanagement.models.ApiManagementSkuCapacity - :ivar locations: The set of locations that the SKU is available. - :vartype locations: list[str] - :ivar location_info: A list of locations and availability zones in those locations where the - SKU is available. - :vartype location_info: list[~azure.mgmt.apimanagement.models.ApiManagementSkuLocationInfo] - :ivar api_versions: The api versions that support this SKU. - :vartype api_versions: list[str] - :ivar costs: Metadata for retrieving price info. - :vartype costs: list[~azure.mgmt.apimanagement.models.ApiManagementSkuCosts] - :ivar capabilities: A name value pair to describe the capability. - :vartype capabilities: list[~azure.mgmt.apimanagement.models.ApiManagementSkuCapabilities] - :ivar restrictions: The restrictions because of which SKU cannot be used. This is empty if - there are no restrictions. - :vartype restrictions: list[~azure.mgmt.apimanagement.models.ApiManagementSkuRestrictions] - """ - - _validation = { - 'resource_type': {'readonly': True}, - 'name': {'readonly': True}, - 'tier': {'readonly': True}, - 'size': {'readonly': True}, - 'family': {'readonly': True}, - 'kind': {'readonly': True}, - 'capacity': {'readonly': True}, - 'locations': {'readonly': True}, - 'location_info': {'readonly': True}, - 'api_versions': {'readonly': True}, - 'costs': {'readonly': True}, - 'capabilities': {'readonly': True}, - 'restrictions': {'readonly': True}, - } - - _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'ApiManagementSkuCapacity'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[ApiManagementSkuLocationInfo]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'costs': {'key': 'costs', 'type': '[ApiManagementSkuCosts]'}, - 'capabilities': {'key': 'capabilities', 'type': '[ApiManagementSkuCapabilities]'}, - 'restrictions': {'key': 'restrictions', 'type': '[ApiManagementSkuRestrictions]'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementSku, self).__init__(**kwargs) - self.resource_type = None - self.name = None - self.tier = None - self.size = None - self.family = None - self.kind = None - self.capacity = None - self.locations = None - self.location_info = None - self.api_versions = None - self.costs = None - self.capabilities = None - self.restrictions = None - - -class ApiManagementSkuCapabilities(msrest.serialization.Model): - """Describes The SKU capabilities object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: An invariant to describe the feature. - :vartype name: str - :ivar value: An invariant if the feature is measured by quantity. - :vartype value: str - """ - - _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementSkuCapabilities, self).__init__(**kwargs) - self.name = None - self.value = None - - -class ApiManagementSkuCapacity(msrest.serialization.Model): - """Describes scaling information of a SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar minimum: The minimum capacity. - :vartype minimum: int - :ivar maximum: The maximum capacity that can be set. - :vartype maximum: int - :ivar default: The default capacity. - :vartype default: int - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "Manual", "None". - :vartype scale_type: str or ~azure.mgmt.apimanagement.models.ApiManagementSkuCapacityScaleType - """ - - _validation = { - 'minimum': {'readonly': True}, - 'maximum': {'readonly': True}, - 'default': {'readonly': True}, - 'scale_type': {'readonly': True}, - } - - _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'int'}, - 'maximum': {'key': 'maximum', 'type': 'int'}, - 'default': {'key': 'default', 'type': 'int'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementSkuCapacity, self).__init__(**kwargs) - self.minimum = None - self.maximum = None - self.default = None - self.scale_type = None - - -class ApiManagementSkuCosts(msrest.serialization.Model): - """Describes metadata for retrieving price info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar meter_id: Used for querying price from commerce. - :vartype meter_id: str - :ivar quantity: The multiplier is needed to extend the base metered cost. - :vartype quantity: long - :ivar extended_unit: An invariant to show the extended unit. - :vartype extended_unit: str - """ - - _validation = { - 'meter_id': {'readonly': True}, - 'quantity': {'readonly': True}, - 'extended_unit': {'readonly': True}, - } - - _attribute_map = { - 'meter_id': {'key': 'meterID', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'long'}, - 'extended_unit': {'key': 'extendedUnit', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementSkuCosts, self).__init__(**kwargs) - self.meter_id = None - self.quantity = None - self.extended_unit = None - - -class ApiManagementSkuLocationInfo(msrest.serialization.Model): - """ApiManagementSkuLocationInfo. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: Location of the SKU. - :vartype location: str - :ivar zones: List of availability zones where the SKU is supported. - :vartype zones: list[str] - :ivar zone_details: Details of capabilities available to a SKU in specific zones. - :vartype zone_details: list[~azure.mgmt.apimanagement.models.ApiManagementSkuZoneDetails] - """ - - _validation = { - 'location': {'readonly': True}, - 'zones': {'readonly': True}, - 'zone_details': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'zone_details': {'key': 'zoneDetails', 'type': '[ApiManagementSkuZoneDetails]'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementSkuLocationInfo, self).__init__(**kwargs) - self.location = None - self.zones = None - self.zone_details = None - - -class ApiManagementSkuRestrictionInfo(msrest.serialization.Model): - """ApiManagementSkuRestrictionInfo. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar locations: Locations where the SKU is restricted. - :vartype locations: list[str] - :ivar zones: List of availability zones where the SKU is restricted. - :vartype zones: list[str] - """ - - _validation = { - 'locations': {'readonly': True}, - 'zones': {'readonly': True}, - } - - _attribute_map = { - 'locations': {'key': 'locations', 'type': '[str]'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementSkuRestrictionInfo, self).__init__(**kwargs) - self.locations = None - self.zones = None - - -class ApiManagementSkuRestrictions(msrest.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 ~azure.mgmt.apimanagement.models.ApiManagementSkuRestrictionsType - :ivar values: The value of restrictions. If the restriction type is set to location. This would - be different locations where the SKU is restricted. - :vartype values: list[str] - :ivar restriction_info: The information about the restriction where the SKU cannot be used. - :vartype restriction_info: ~azure.mgmt.apimanagement.models.ApiManagementSkuRestrictionInfo - :ivar reason_code: The reason for restriction. Possible values include: "QuotaId", - "NotAvailableForSubscription". - :vartype reason_code: str or - ~azure.mgmt.apimanagement.models.ApiManagementSkuRestrictionsReasonCode - """ - - _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, - 'restriction_info': {'readonly': True}, - 'reason_code': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'restriction_info': {'key': 'restrictionInfo', 'type': 'ApiManagementSkuRestrictionInfo'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementSkuRestrictions, self).__init__(**kwargs) - self.type = None - self.values = None - self.restriction_info = None - self.reason_code = None - - -class ApiManagementSkusResult(msrest.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. - - :param value: Required. The list of skus available for the subscription. - :type value: list[~azure.mgmt.apimanagement.models.ApiManagementSku] - :ivar next_link: The URI to fetch the next page of Resource Skus. Call ListNext() with this URI - to fetch the next page of Resource Skus. - :vartype next_link: str - """ - - _validation = { - 'value': {'required': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ApiManagementSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementSkusResult, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = None - - -class ApiManagementSkuZoneDetails(msrest.serialization.Model): - """Describes The zonal capabilities of a SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The set of zones that the SKU is available in with the specified capabilities. - :vartype name: list[str] - :ivar capabilities: A list of capabilities that are available for the SKU in the specified list - of zones. - :vartype capabilities: list[~azure.mgmt.apimanagement.models.ApiManagementSkuCapabilities] - """ - - _validation = { - 'name': {'readonly': True}, - 'capabilities': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[ApiManagementSkuCapabilities]'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiManagementSkuZoneDetails, self).__init__(**kwargs) - self.name = None - self.capabilities = None - - -class ApiReleaseCollection(msrest.serialization.Model): - """Paged ApiRelease list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.ApiReleaseContract] - :param count: Total record count number across all pages. - :type count: long - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ApiReleaseContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiReleaseCollection, self).__init__(**kwargs) - self.value = None - self.count = kwargs.get('count', None) - self.next_link = None - - -class ApiReleaseContract(Resource): - """ApiRelease details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param api_id: Identifier of the API the release belongs to. - :type api_id: str - :ivar created_date_time: The time the API was released. The date conforms to the following - format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. - :vartype created_date_time: ~datetime.datetime - :ivar updated_date_time: The time the API release was updated. - :vartype updated_date_time: ~datetime.datetime - :param notes: Release Notes. - :type notes: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'created_date_time': {'readonly': True}, - 'updated_date_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'api_id': {'key': 'properties.apiId', 'type': 'str'}, - 'created_date_time': {'key': 'properties.createdDateTime', 'type': 'iso-8601'}, - 'updated_date_time': {'key': 'properties.updatedDateTime', 'type': 'iso-8601'}, - 'notes': {'key': 'properties.notes', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiReleaseContract, self).__init__(**kwargs) - self.api_id = kwargs.get('api_id', None) - self.created_date_time = None - self.updated_date_time = None - self.notes = kwargs.get('notes', None) - - -class ApiRevisionCollection(msrest.serialization.Model): - """Paged Api Revision list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.ApiRevisionContract] - :param count: Total record count number across all pages. - :type count: long - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ApiRevisionContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiRevisionCollection, self).__init__(**kwargs) - self.value = None - self.count = kwargs.get('count', None) - self.next_link = None - - -class ApiRevisionContract(msrest.serialization.Model): - """Summary of revision metadata. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar api_id: Identifier of the API Revision. - :vartype api_id: str - :ivar api_revision: Revision number of API. - :vartype api_revision: str - :ivar created_date_time: The time the API Revision was created. The date conforms to the - following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. - :vartype created_date_time: ~datetime.datetime - :ivar updated_date_time: The time the API Revision were updated. The date conforms to the - following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. - :vartype updated_date_time: ~datetime.datetime - :ivar description: Description of the API Revision. - :vartype description: str - :ivar private_url: Gateway URL for accessing the non-current API Revision. - :vartype private_url: str - :ivar is_online: Indicates if API revision is the current api revision. - :vartype is_online: bool - :ivar is_current: Indicates if API revision is accessible via the gateway. - :vartype is_current: bool - """ - - _validation = { - 'api_id': {'readonly': True}, - 'api_revision': {'readonly': True, 'max_length': 100, 'min_length': 1}, - 'created_date_time': {'readonly': True}, - 'updated_date_time': {'readonly': True}, - 'description': {'readonly': True, 'max_length': 256, '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) - self.api_id = None - self.api_revision = None - self.created_date_time = None - self.updated_date_time = None - self.description = None - self.private_url = None - self.is_online = None - self.is_current = None - - -class ApiRevisionInfoContract(msrest.serialization.Model): - """Object used to create an API Revision or Version based on an existing API Revision. - - :param source_api_id: Resource identifier of API to be used to create the revision from. - :type source_api_id: str - :param api_version_name: Version identifier for the new API Version. - :type api_version_name: str - :param api_revision_description: Description of new API Revision. - :type api_revision_description: str - :param api_version_set: Version set details. - :type 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}, - } - - _attribute_map = { - 'source_api_id': {'key': 'sourceApiId', 'type': 'str'}, - 'api_version_name': {'key': 'apiVersionName', 'type': 'str'}, - 'api_revision_description': {'key': 'apiRevisionDescription', 'type': 'str'}, - 'api_version_set': {'key': 'apiVersionSet', 'type': 'ApiVersionSetContractDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiRevisionInfoContract, self).__init__(**kwargs) - self.source_api_id = kwargs.get('source_api_id', None) - self.api_version_name = kwargs.get('api_version_name', None) - self.api_revision_description = kwargs.get('api_revision_description', None) - self.api_version_set = kwargs.get('api_version_set', None) - - -class ApiTagResourceContractProperties(ApiEntityBaseContract): - """API contract properties for the Tag Resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param description: Description of the API. May include HTML formatting tags. - :type description: str - :param authentication_settings: Collection of authentication settings included into this API. - :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made available. - :type subscription_key_parameter_names: - ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: "http", "soap". - :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is provided, default - revision 1 is created. - :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API is versioned. - :type api_version: str - :param is_current: Indicates if API revision is current api revision. - :type is_current: bool - :ivar is_online: Indicates if API revision is accessible via the gateway. - :vartype is_online: bool - :param api_revision_description: Description of the Api Revision. - :type api_revision_description: str - :param api_version_description: Description of the Api Version. - :type api_version_description: str - :param api_version_set_id: A resource identifier for the related ApiVersionSet. - :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product subscription is required for - accessing the API. - :type subscription_required: bool - :param id: API identifier in the form /apis/{apiId}. - :type id: str - :param name: API name. - :type name: str - :param service_url: Absolute URL of the backend service implementing this API. - :type service_url: str - :param 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. - :type path: str - :param protocols: Describes on which protocols the operations in this API can be invoked. - :type 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'}, - '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, - **kwargs - ): - super(ApiTagResourceContractProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.service_url = kwargs.get('service_url', None) - self.path = kwargs.get('path', None) - self.protocols = kwargs.get('protocols', None) - - -class ApiUpdateContract(msrest.serialization.Model): - """API update contract details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param description: Description of the API. May include HTML formatting tags. - :type description: str - :param authentication_settings: Collection of authentication settings included into this API. - :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made available. - :type subscription_key_parameter_names: - ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: "http", "soap". - :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is provided, default - revision 1 is created. - :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API is versioned. - :type api_version: str - :param is_current: Indicates if API revision is current api revision. - :type is_current: bool - :ivar is_online: Indicates if API revision is accessible via the gateway. - :vartype is_online: bool - :param api_revision_description: Description of the Api Revision. - :type api_revision_description: str - :param api_version_description: Description of the Api Version. - :type api_version_description: str - :param api_version_set_id: A resource identifier for the related ApiVersionSet. - :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product subscription is required for - accessing the API. - :type subscription_required: bool - :param display_name: API name. - :type display_name: str - :param service_url: Absolute URL of the backend service implementing this API. - :type service_url: str - :param 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. - :type path: str - :param protocols: Describes on which protocols the operations in this API can be invoked. - :type 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'}, - '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, - **kwargs - ): - super(ApiUpdateContract, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.authentication_settings = kwargs.get('authentication_settings', None) - self.subscription_key_parameter_names = kwargs.get('subscription_key_parameter_names', None) - self.api_type = kwargs.get('api_type', None) - self.api_revision = kwargs.get('api_revision', None) - self.api_version = kwargs.get('api_version', None) - self.is_current = kwargs.get('is_current', None) - self.is_online = None - self.api_revision_description = kwargs.get('api_revision_description', None) - self.api_version_description = kwargs.get('api_version_description', None) - self.api_version_set_id = kwargs.get('api_version_set_id', None) - self.subscription_required = kwargs.get('subscription_required', None) - self.display_name = kwargs.get('display_name', None) - self.service_url = kwargs.get('service_url', None) - self.path = kwargs.get('path', None) - self.protocols = kwargs.get('protocols', None) - - -class ApiVersionConstraint(msrest.serialization.Model): - """Control Plane Apis version constraint for the API Management service. - - :param min_api_version: Limit control plane API calls to API Management service with version - equal to or newer than this value. - :type min_api_version: str - """ - - _attribute_map = { - 'min_api_version': {'key': 'minApiVersion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiVersionConstraint, self).__init__(**kwargs) - self.min_api_version = kwargs.get('min_api_version', None) - - -class ApiVersionSetCollection(msrest.serialization.Model): - """Paged Api Version Set list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.ApiVersionSetContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ApiVersionSetContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiVersionSetCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class ApiVersionSetContract(Resource): - """Api Version Set Contract details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param description: Description of API Version Set. - :type description: str - :param version_query_name: Name of query parameter that indicates the API Version if - versioningScheme is set to ``query``. - :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates the API Version if - versioningScheme is set to ``header``. - :type version_header_name: str - :param display_name: Name of API Version Set. - :type display_name: str - :param versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Possible values include: "Segment", "Query", "Header". - :type versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'version_query_name': {'max_length': 100, 'min_length': 1}, - 'version_header_name': {'max_length': 100, 'min_length': 1}, - 'display_name': {'max_length': 100, 'min_length': 1}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'version_query_name': {'key': 'properties.versionQueryName', 'type': 'str'}, - 'version_header_name': {'key': 'properties.versionHeaderName', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'versioning_scheme': {'key': 'properties.versioningScheme', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiVersionSetContract, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.version_query_name = kwargs.get('version_query_name', None) - self.version_header_name = kwargs.get('version_header_name', None) - self.display_name = kwargs.get('display_name', None) - self.versioning_scheme = kwargs.get('versioning_scheme', None) - - -class ApiVersionSetContractDetails(msrest.serialization.Model): - """An API Version Set contains the common configuration for a set of API Versions relating. - - :param id: Identifier for existing API Version Set. Omit this value to create a new Version - Set. - :type id: str - :param name: The display Name of the API Version Set. - :type name: str - :param description: Description of API Version Set. - :type description: str - :param versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Possible values include: "Segment", "Query", "Header". - :type versioning_scheme: str or - ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetailsVersioningScheme - :param version_query_name: Name of query parameter that indicates the API Version if - versioningScheme is set to ``query``. - :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates the API Version if - versioningScheme is set to ``header``. - :type version_header_name: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'versioning_scheme': {'key': 'versioningScheme', 'type': 'str'}, - 'version_query_name': {'key': 'versionQueryName', 'type': 'str'}, - 'version_header_name': {'key': 'versionHeaderName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiVersionSetContractDetails, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.description = kwargs.get('description', None) - self.versioning_scheme = kwargs.get('versioning_scheme', None) - self.version_query_name = kwargs.get('version_query_name', None) - self.version_header_name = kwargs.get('version_header_name', None) - - -class ApiVersionSetEntityBase(msrest.serialization.Model): - """Api Version set base parameters. - - :param description: Description of API Version Set. - :type description: str - :param version_query_name: Name of query parameter that indicates the API Version if - versioningScheme is set to ``query``. - :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates the API Version if - versioningScheme is set to ``header``. - :type version_header_name: str - """ - - _validation = { - 'version_query_name': {'max_length': 100, 'min_length': 1}, - 'version_header_name': {'max_length': 100, 'min_length': 1}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'version_query_name': {'key': 'versionQueryName', 'type': 'str'}, - 'version_header_name': {'key': 'versionHeaderName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiVersionSetEntityBase, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.version_query_name = kwargs.get('version_query_name', None) - self.version_header_name = kwargs.get('version_header_name', None) - - -class ApiVersionSetContractProperties(ApiVersionSetEntityBase): - """Properties of an API Version Set. - - All required parameters must be populated in order to send to Azure. - - :param description: Description of API Version Set. - :type description: str - :param version_query_name: Name of query parameter that indicates the API Version if - versioningScheme is set to ``query``. - :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates the API Version if - versioningScheme is set to ``header``. - :type version_header_name: str - :param display_name: Required. Name of API Version Set. - :type display_name: str - :param 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". - :type versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme - """ - - _validation = { - 'version_query_name': {'max_length': 100, 'min_length': 1}, - 'version_header_name': {'max_length': 100, 'min_length': 1}, - 'display_name': {'required': True, 'max_length': 100, 'min_length': 1}, - 'versioning_scheme': {'required': True}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'version_query_name': {'key': 'versionQueryName', 'type': 'str'}, - 'version_header_name': {'key': 'versionHeaderName', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'versioning_scheme': {'key': 'versioningScheme', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiVersionSetContractProperties, self).__init__(**kwargs) - self.display_name = kwargs['display_name'] - self.versioning_scheme = kwargs['versioning_scheme'] - - -class ApiVersionSetUpdateParameters(msrest.serialization.Model): - """Parameters to update or create an Api Version Set Contract. - - :param description: Description of API Version Set. - :type description: str - :param version_query_name: Name of query parameter that indicates the API Version if - versioningScheme is set to ``query``. - :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates the API Version if - versioningScheme is set to ``header``. - :type version_header_name: str - :param display_name: Name of API Version Set. - :type display_name: str - :param versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Possible values include: "Segment", "Query", "Header". - :type versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme - """ - - _validation = { - 'version_query_name': {'max_length': 100, 'min_length': 1}, - 'version_header_name': {'max_length': 100, 'min_length': 1}, - 'display_name': {'max_length': 100, 'min_length': 1}, - } - - _attribute_map = { - 'description': {'key': 'properties.description', 'type': 'str'}, - 'version_query_name': {'key': 'properties.versionQueryName', 'type': 'str'}, - 'version_header_name': {'key': 'properties.versionHeaderName', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'versioning_scheme': {'key': 'properties.versioningScheme', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiVersionSetUpdateParameters, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.version_query_name = kwargs.get('version_query_name', None) - self.version_header_name = kwargs.get('version_header_name', None) - self.display_name = kwargs.get('display_name', None) - self.versioning_scheme = kwargs.get('versioning_scheme', None) - - -class ApiVersionSetUpdateParametersProperties(ApiVersionSetEntityBase): - """Properties used to create or update an API Version Set. - - :param description: Description of API Version Set. - :type description: str - :param version_query_name: Name of query parameter that indicates the API Version if - versioningScheme is set to ``query``. - :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates the API Version if - versioningScheme is set to ``header``. - :type version_header_name: str - :param display_name: Name of API Version Set. - :type display_name: str - :param versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Possible values include: "Segment", "Query", "Header". - :type versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme - """ - - _validation = { - 'version_query_name': {'max_length': 100, 'min_length': 1}, - 'version_header_name': {'max_length': 100, 'min_length': 1}, - 'display_name': {'max_length': 100, 'min_length': 1}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'version_query_name': {'key': 'versionQueryName', 'type': 'str'}, - 'version_header_name': {'key': 'versionHeaderName', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'versioning_scheme': {'key': 'versioningScheme', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiVersionSetUpdateParametersProperties, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.versioning_scheme = kwargs.get('versioning_scheme', None) - - -class AssociationContract(Resource): - """Association entity details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param provisioning_state: Provisioning state. The only acceptable values to pass in are None - and "created". The default value is None. - :type provisioning_state: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AssociationContract, self).__init__(**kwargs) - self.provisioning_state = kwargs.get('provisioning_state', None) - - -class AuthenticationSettingsContract(msrest.serialization.Model): - """API Authentication Settings. - - :param o_auth2: OAuth2 Authentication settings. - :type o_auth2: ~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract - :param openid: OpenID Connect Authentication Settings. - :type openid: ~azure.mgmt.apimanagement.models.OpenIdAuthenticationSettingsContract - """ - - _attribute_map = { - 'o_auth2': {'key': 'oAuth2', 'type': 'OAuth2AuthenticationSettingsContract'}, - 'openid': {'key': 'openid', 'type': 'OpenIdAuthenticationSettingsContract'}, - } - - def __init__( - self, - **kwargs - ): - super(AuthenticationSettingsContract, self).__init__(**kwargs) - self.o_auth2 = kwargs.get('o_auth2', None) - self.openid = kwargs.get('openid', None) - - -class AuthorizationServerCollection(msrest.serialization.Model): - """Paged OAuth2 Authorization Servers list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.AuthorizationServerContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AuthorizationServerContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AuthorizationServerCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class AuthorizationServerContract(Resource): - """External OAuth authorization server settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param description: Description of the authorization server. Can contain HTML formatting tags. - :type description: str - :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be - always present. POST is optional. - :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :param 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. - :type client_authentication_method: list[str or - ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :param 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"}. - :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. - :type token_endpoint: str - :param support_state: If true, authorization server will include state parameter from the - authorization request to its response. Client may use state parameter to raise protocol - security. - :type support_state: bool - :param default_scope: Access token scope that is going to be requested by default. Can be - overridden at the API level. Should be provided in the form of a string containing - space-delimited values. - :type default_scope: str - :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to - the API. - :type bearer_token_sending_methods: list[str or - ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :param resource_owner_username: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner username. - :type resource_owner_username: str - :param resource_owner_password: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner password. - :type resource_owner_password: str - :param display_name: User-friendly authorization server name. - :type display_name: str - :param 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. - :type client_registration_endpoint: str - :param authorization_endpoint: OAuth authorization endpoint. See - http://tools.ietf.org/html/rfc6749#section-3.2. - :type authorization_endpoint: str - :param grant_types: Form of an authorization grant, which the client uses to request the access - token. - :type grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :param client_id: Client or app id registered with this authorization server. - :type client_id: str - :param 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. - :type client_secret: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'max_length': 50, 'min_length': 1}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'authorization_methods': {'key': 'properties.authorizationMethods', 'type': '[str]'}, - 'client_authentication_method': {'key': 'properties.clientAuthenticationMethod', 'type': '[str]'}, - 'token_body_parameters': {'key': 'properties.tokenBodyParameters', 'type': '[TokenBodyParameterContract]'}, - 'token_endpoint': {'key': 'properties.tokenEndpoint', 'type': 'str'}, - 'support_state': {'key': 'properties.supportState', 'type': 'bool'}, - 'default_scope': {'key': 'properties.defaultScope', 'type': 'str'}, - 'bearer_token_sending_methods': {'key': 'properties.bearerTokenSendingMethods', 'type': '[str]'}, - 'resource_owner_username': {'key': 'properties.resourceOwnerUsername', 'type': 'str'}, - 'resource_owner_password': {'key': 'properties.resourceOwnerPassword', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - '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, - **kwargs - ): - super(AuthorizationServerContract, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.authorization_methods = kwargs.get('authorization_methods', None) - self.client_authentication_method = kwargs.get('client_authentication_method', None) - self.token_body_parameters = kwargs.get('token_body_parameters', None) - self.token_endpoint = kwargs.get('token_endpoint', None) - self.support_state = kwargs.get('support_state', None) - self.default_scope = kwargs.get('default_scope', None) - self.bearer_token_sending_methods = kwargs.get('bearer_token_sending_methods', None) - self.resource_owner_username = kwargs.get('resource_owner_username', None) - self.resource_owner_password = kwargs.get('resource_owner_password', None) - self.display_name = kwargs.get('display_name', None) - self.client_registration_endpoint = kwargs.get('client_registration_endpoint', None) - self.authorization_endpoint = kwargs.get('authorization_endpoint', None) - self.grant_types = kwargs.get('grant_types', None) - self.client_id = kwargs.get('client_id', None) - self.client_secret = kwargs.get('client_secret', None) - - -class AuthorizationServerContractBaseProperties(msrest.serialization.Model): - """External OAuth authorization server Update settings contract. - - :param description: Description of the authorization server. Can contain HTML formatting tags. - :type description: str - :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be - always present. POST is optional. - :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :param 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. - :type client_authentication_method: list[str or - ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :param 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"}. - :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. - :type token_endpoint: str - :param support_state: If true, authorization server will include state parameter from the - authorization request to its response. Client may use state parameter to raise protocol - security. - :type support_state: bool - :param default_scope: Access token scope that is going to be requested by default. Can be - overridden at the API level. Should be provided in the form of a string containing - space-delimited values. - :type default_scope: str - :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to - the API. - :type bearer_token_sending_methods: list[str or - ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :param resource_owner_username: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner username. - :type resource_owner_username: str - :param resource_owner_password: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner password. - :type resource_owner_password: str - """ - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'authorization_methods': {'key': 'authorizationMethods', 'type': '[str]'}, - 'client_authentication_method': {'key': 'clientAuthenticationMethod', 'type': '[str]'}, - 'token_body_parameters': {'key': 'tokenBodyParameters', 'type': '[TokenBodyParameterContract]'}, - 'token_endpoint': {'key': 'tokenEndpoint', 'type': 'str'}, - 'support_state': {'key': 'supportState', 'type': 'bool'}, - 'default_scope': {'key': 'defaultScope', 'type': 'str'}, - 'bearer_token_sending_methods': {'key': 'bearerTokenSendingMethods', 'type': '[str]'}, - 'resource_owner_username': {'key': 'resourceOwnerUsername', 'type': 'str'}, - 'resource_owner_password': {'key': 'resourceOwnerPassword', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AuthorizationServerContractBaseProperties, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.authorization_methods = kwargs.get('authorization_methods', None) - self.client_authentication_method = kwargs.get('client_authentication_method', None) - self.token_body_parameters = kwargs.get('token_body_parameters', None) - self.token_endpoint = kwargs.get('token_endpoint', None) - self.support_state = kwargs.get('support_state', None) - self.default_scope = kwargs.get('default_scope', None) - self.bearer_token_sending_methods = kwargs.get('bearer_token_sending_methods', None) - self.resource_owner_username = kwargs.get('resource_owner_username', None) - self.resource_owner_password = kwargs.get('resource_owner_password', None) - - -class AuthorizationServerContractProperties(AuthorizationServerContractBaseProperties): - """External OAuth authorization server settings Properties. - - All required parameters must be populated in order to send to Azure. - - :param description: Description of the authorization server. Can contain HTML formatting tags. - :type description: str - :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be - always present. POST is optional. - :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :param 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. - :type client_authentication_method: list[str or - ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :param 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"}. - :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. - :type token_endpoint: str - :param support_state: If true, authorization server will include state parameter from the - authorization request to its response. Client may use state parameter to raise protocol - security. - :type support_state: bool - :param default_scope: Access token scope that is going to be requested by default. Can be - overridden at the API level. Should be provided in the form of a string containing - space-delimited values. - :type default_scope: str - :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to - the API. - :type bearer_token_sending_methods: list[str or - ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :param resource_owner_username: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner username. - :type resource_owner_username: str - :param resource_owner_password: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner password. - :type resource_owner_password: str - :param display_name: Required. User-friendly authorization server name. - :type display_name: str - :param 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. - :type client_registration_endpoint: str - :param authorization_endpoint: Required. OAuth authorization endpoint. See - http://tools.ietf.org/html/rfc6749#section-3.2. - :type authorization_endpoint: str - :param grant_types: Required. Form of an authorization grant, which the client uses to request - the access token. - :type grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :param client_id: Required. Client or app id registered with this authorization server. - :type client_id: str - :param 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. - :type client_secret: str - """ - - _validation = { - 'display_name': {'required': True, 'max_length': 50, 'min_length': 1}, - 'client_registration_endpoint': {'required': True}, - 'authorization_endpoint': {'required': True}, - 'grant_types': {'required': True}, - 'client_id': {'required': True}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'authorization_methods': {'key': 'authorizationMethods', 'type': '[str]'}, - 'client_authentication_method': {'key': 'clientAuthenticationMethod', 'type': '[str]'}, - 'token_body_parameters': {'key': 'tokenBodyParameters', 'type': '[TokenBodyParameterContract]'}, - 'token_endpoint': {'key': 'tokenEndpoint', 'type': 'str'}, - 'support_state': {'key': 'supportState', 'type': 'bool'}, - 'default_scope': {'key': 'defaultScope', 'type': 'str'}, - 'bearer_token_sending_methods': {'key': 'bearerTokenSendingMethods', 'type': '[str]'}, - 'resource_owner_username': {'key': 'resourceOwnerUsername', 'type': 'str'}, - 'resource_owner_password': {'key': 'resourceOwnerPassword', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - '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, - **kwargs - ): - super(AuthorizationServerContractProperties, self).__init__(**kwargs) - self.display_name = kwargs['display_name'] - self.client_registration_endpoint = kwargs['client_registration_endpoint'] - self.authorization_endpoint = kwargs['authorization_endpoint'] - self.grant_types = kwargs['grant_types'] - self.client_id = kwargs['client_id'] - self.client_secret = kwargs.get('client_secret', None) - - -class AuthorizationServerSecretsContract(msrest.serialization.Model): - """OAuth Server Secrets Contract. - - :param client_secret: oAuth Authorization Server Secrets. - :type client_secret: str - :param resource_owner_username: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner username. - :type resource_owner_username: str - :param resource_owner_password: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner password. - :type resource_owner_password: str - """ - - _attribute_map = { - 'client_secret': {'key': 'clientSecret', 'type': 'str'}, - 'resource_owner_username': {'key': 'resourceOwnerUsername', 'type': 'str'}, - 'resource_owner_password': {'key': 'resourceOwnerPassword', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AuthorizationServerSecretsContract, self).__init__(**kwargs) - self.client_secret = kwargs.get('client_secret', None) - self.resource_owner_username = kwargs.get('resource_owner_username', None) - self.resource_owner_password = kwargs.get('resource_owner_password', None) - - -class AuthorizationServerUpdateContract(Resource): - """External OAuth authorization server settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param description: Description of the authorization server. Can contain HTML formatting tags. - :type description: str - :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be - always present. POST is optional. - :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :param 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. - :type client_authentication_method: list[str or - ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :param 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"}. - :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. - :type token_endpoint: str - :param support_state: If true, authorization server will include state parameter from the - authorization request to its response. Client may use state parameter to raise protocol - security. - :type support_state: bool - :param default_scope: Access token scope that is going to be requested by default. Can be - overridden at the API level. Should be provided in the form of a string containing - space-delimited values. - :type default_scope: str - :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to - the API. - :type bearer_token_sending_methods: list[str or - ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :param resource_owner_username: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner username. - :type resource_owner_username: str - :param resource_owner_password: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner password. - :type resource_owner_password: str - :param display_name: User-friendly authorization server name. - :type display_name: str - :param 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. - :type client_registration_endpoint: str - :param authorization_endpoint: OAuth authorization endpoint. See - http://tools.ietf.org/html/rfc6749#section-3.2. - :type authorization_endpoint: str - :param grant_types: Form of an authorization grant, which the client uses to request the access - token. - :type grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :param client_id: Client or app id registered with this authorization server. - :type client_id: str - :param 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. - :type client_secret: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'max_length': 50, 'min_length': 1}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'authorization_methods': {'key': 'properties.authorizationMethods', 'type': '[str]'}, - 'client_authentication_method': {'key': 'properties.clientAuthenticationMethod', 'type': '[str]'}, - 'token_body_parameters': {'key': 'properties.tokenBodyParameters', 'type': '[TokenBodyParameterContract]'}, - 'token_endpoint': {'key': 'properties.tokenEndpoint', 'type': 'str'}, - 'support_state': {'key': 'properties.supportState', 'type': 'bool'}, - 'default_scope': {'key': 'properties.defaultScope', 'type': 'str'}, - 'bearer_token_sending_methods': {'key': 'properties.bearerTokenSendingMethods', 'type': '[str]'}, - 'resource_owner_username': {'key': 'properties.resourceOwnerUsername', 'type': 'str'}, - 'resource_owner_password': {'key': 'properties.resourceOwnerPassword', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - '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, - **kwargs - ): - super(AuthorizationServerUpdateContract, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.authorization_methods = kwargs.get('authorization_methods', None) - self.client_authentication_method = kwargs.get('client_authentication_method', None) - self.token_body_parameters = kwargs.get('token_body_parameters', None) - self.token_endpoint = kwargs.get('token_endpoint', None) - self.support_state = kwargs.get('support_state', None) - self.default_scope = kwargs.get('default_scope', None) - self.bearer_token_sending_methods = kwargs.get('bearer_token_sending_methods', None) - self.resource_owner_username = kwargs.get('resource_owner_username', None) - self.resource_owner_password = kwargs.get('resource_owner_password', None) - self.display_name = kwargs.get('display_name', None) - self.client_registration_endpoint = kwargs.get('client_registration_endpoint', None) - self.authorization_endpoint = kwargs.get('authorization_endpoint', None) - self.grant_types = kwargs.get('grant_types', None) - self.client_id = kwargs.get('client_id', None) - self.client_secret = kwargs.get('client_secret', None) - - -class AuthorizationServerUpdateContractProperties(AuthorizationServerContractBaseProperties): - """External OAuth authorization server Update settings contract. - - :param description: Description of the authorization server. Can contain HTML formatting tags. - :type description: str - :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be - always present. POST is optional. - :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :param 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. - :type client_authentication_method: list[str or - ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :param 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"}. - :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. - :type token_endpoint: str - :param support_state: If true, authorization server will include state parameter from the - authorization request to its response. Client may use state parameter to raise protocol - security. - :type support_state: bool - :param default_scope: Access token scope that is going to be requested by default. Can be - overridden at the API level. Should be provided in the form of a string containing - space-delimited values. - :type default_scope: str - :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to - the API. - :type bearer_token_sending_methods: list[str or - ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :param resource_owner_username: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner username. - :type resource_owner_username: str - :param resource_owner_password: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner password. - :type resource_owner_password: str - :param display_name: User-friendly authorization server name. - :type display_name: str - :param 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. - :type client_registration_endpoint: str - :param authorization_endpoint: OAuth authorization endpoint. See - http://tools.ietf.org/html/rfc6749#section-3.2. - :type authorization_endpoint: str - :param grant_types: Form of an authorization grant, which the client uses to request the access - token. - :type grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :param client_id: Client or app id registered with this authorization server. - :type client_id: str - :param 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. - :type client_secret: str - """ - - _validation = { - 'display_name': {'max_length': 50, 'min_length': 1}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'authorization_methods': {'key': 'authorizationMethods', 'type': '[str]'}, - 'client_authentication_method': {'key': 'clientAuthenticationMethod', 'type': '[str]'}, - 'token_body_parameters': {'key': 'tokenBodyParameters', 'type': '[TokenBodyParameterContract]'}, - 'token_endpoint': {'key': 'tokenEndpoint', 'type': 'str'}, - 'support_state': {'key': 'supportState', 'type': 'bool'}, - 'default_scope': {'key': 'defaultScope', 'type': 'str'}, - 'bearer_token_sending_methods': {'key': 'bearerTokenSendingMethods', 'type': '[str]'}, - 'resource_owner_username': {'key': 'resourceOwnerUsername', 'type': 'str'}, - 'resource_owner_password': {'key': 'resourceOwnerPassword', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - '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, - **kwargs - ): - super(AuthorizationServerUpdateContractProperties, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.client_registration_endpoint = kwargs.get('client_registration_endpoint', None) - self.authorization_endpoint = kwargs.get('authorization_endpoint', None) - self.grant_types = kwargs.get('grant_types', None) - self.client_id = kwargs.get('client_id', None) - self.client_secret = kwargs.get('client_secret', None) - - -class BackendAuthorizationHeaderCredentials(msrest.serialization.Model): - """Authorization header information. - - All required parameters must be populated in order to send to Azure. - - :param scheme: Required. Authentication Scheme name. - :type scheme: str - :param parameter: Required. Authentication Parameter value. - :type parameter: str - """ - - _validation = { - 'scheme': {'required': True, 'max_length': 100, 'min_length': 1}, - 'parameter': {'required': True, 'max_length': 300, 'min_length': 1}, - } - - _attribute_map = { - 'scheme': {'key': 'scheme', 'type': 'str'}, - 'parameter': {'key': 'parameter', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BackendAuthorizationHeaderCredentials, self).__init__(**kwargs) - self.scheme = kwargs['scheme'] - self.parameter = kwargs['parameter'] - - -class BackendBaseParameters(msrest.serialization.Model): - """Backend entity base Parameter set. - - :param title: Backend Title. - :type title: str - :param description: Backend Description. - :type description: str - :param resource_id: Management Uri of the Resource in External System. This url can be the Arm - Resource Id of Logic Apps, Function Apps or Api Apps. - :type resource_id: str - :param properties: Backend Properties contract. - :type properties: ~azure.mgmt.apimanagement.models.BackendProperties - :param credentials: Backend Credentials Contract Properties. - :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :param proxy: Backend Proxy Contract Properties. - :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract - :param tls: Backend TLS Properties. - :type 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}, - } - - _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'}, - } - - def __init__( - self, - **kwargs - ): - super(BackendBaseParameters, self).__init__(**kwargs) - self.title = kwargs.get('title', None) - self.description = kwargs.get('description', None) - self.resource_id = kwargs.get('resource_id', None) - self.properties = kwargs.get('properties', None) - self.credentials = kwargs.get('credentials', None) - self.proxy = kwargs.get('proxy', None) - self.tls = kwargs.get('tls', None) - - -class BackendCollection(msrest.serialization.Model): - """Paged Backend list representation. - - :param value: Backend values. - :type value: list[~azure.mgmt.apimanagement.models.BackendContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[BackendContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BackendCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class BackendContract(Resource): - """Backend details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param title: Backend Title. - :type title: str - :param description: Backend Description. - :type description: str - :param resource_id: Management Uri of the Resource in External System. This url can be the Arm - Resource Id of Logic Apps, Function Apps or Api Apps. - :type resource_id: str - :param properties: Backend Properties contract. - :type properties: ~azure.mgmt.apimanagement.models.BackendProperties - :param credentials: Backend Credentials Contract Properties. - :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :param proxy: Backend Proxy Contract Properties. - :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract - :param tls: Backend TLS Properties. - :type tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties - :param url: Runtime Url of the Backend. - :type url: str - :param protocol: Backend communication protocol. Possible values include: "http", "soap". - :type 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'}, - } - - def __init__( - self, - **kwargs - ): - super(BackendContract, self).__init__(**kwargs) - self.title = kwargs.get('title', None) - self.description = kwargs.get('description', None) - self.resource_id = kwargs.get('resource_id', None) - self.properties = kwargs.get('properties', None) - self.credentials = kwargs.get('credentials', None) - self.proxy = kwargs.get('proxy', None) - self.tls = kwargs.get('tls', None) - self.url = kwargs.get('url', None) - self.protocol = kwargs.get('protocol', None) - - -class BackendContractProperties(BackendBaseParameters): - """Parameters supplied to the Create Backend operation. - - All required parameters must be populated in order to send to Azure. - - :param title: Backend Title. - :type title: str - :param description: Backend Description. - :type description: str - :param resource_id: Management Uri of the Resource in External System. This url can be the Arm - Resource Id of Logic Apps, Function Apps or Api Apps. - :type resource_id: str - :param properties: Backend Properties contract. - :type properties: ~azure.mgmt.apimanagement.models.BackendProperties - :param credentials: Backend Credentials Contract Properties. - :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :param proxy: Backend Proxy Contract Properties. - :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract - :param tls: Backend TLS Properties. - :type tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties - :param url: Required. Runtime Url of the Backend. - :type url: str - :param protocol: Required. Backend communication protocol. Possible values include: "http", - "soap". - :type protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol - """ - - _validation = { - 'title': {'max_length': 300, 'min_length': 1}, - 'description': {'max_length': 2000, 'min_length': 1}, - 'resource_id': {'max_length': 2000, 'min_length': 1}, - 'url': {'required': True, 'max_length': 2000, 'min_length': 1}, - 'protocol': {'required': True}, - } - - _attribute_map = { - 'title': {'key': 'title', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'BackendProperties'}, - 'credentials': {'key': 'credentials', 'type': 'BackendCredentialsContract'}, - 'proxy': {'key': 'proxy', 'type': 'BackendProxyContract'}, - 'tls': {'key': 'tls', 'type': 'BackendTlsProperties'}, - 'url': {'key': 'url', 'type': 'str'}, - 'protocol': {'key': 'protocol', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BackendContractProperties, self).__init__(**kwargs) - self.url = kwargs['url'] - self.protocol = kwargs['protocol'] - - -class BackendCredentialsContract(msrest.serialization.Model): - """Details of the Credentials used to connect to Backend. - - :param certificate_ids: List of Client Certificate Ids. - :type certificate_ids: list[str] - :param certificate: List of Client Certificate Thumbprints. Will be ignored if certificatesIds - are provided. - :type certificate: list[str] - :param query: Query Parameter description. - :type query: dict[str, list[str]] - :param header: Header Parameter description. - :type header: dict[str, list[str]] - :param authorization: Authorization header authentication. - :type authorization: ~azure.mgmt.apimanagement.models.BackendAuthorizationHeaderCredentials - """ - - _validation = { - 'certificate_ids': {'max_items': 32, 'min_items': 0}, - 'certificate': {'max_items': 32, 'min_items': 0}, - } - - _attribute_map = { - 'certificate_ids': {'key': 'certificateIds', 'type': '[str]'}, - 'certificate': {'key': 'certificate', 'type': '[str]'}, - 'query': {'key': 'query', 'type': '{[str]}'}, - 'header': {'key': 'header', 'type': '{[str]}'}, - 'authorization': {'key': 'authorization', 'type': 'BackendAuthorizationHeaderCredentials'}, - } - - def __init__( - self, - **kwargs - ): - super(BackendCredentialsContract, self).__init__(**kwargs) - self.certificate_ids = kwargs.get('certificate_ids', None) - self.certificate = kwargs.get('certificate', None) - self.query = kwargs.get('query', None) - self.header = kwargs.get('header', None) - self.authorization = kwargs.get('authorization', None) - - -class BackendProperties(msrest.serialization.Model): - """Properties specific to the Backend Type. - - :param service_fabric_cluster: Backend Service Fabric Cluster Properties. - :type service_fabric_cluster: - ~azure.mgmt.apimanagement.models.BackendServiceFabricClusterProperties - """ - - _attribute_map = { - 'service_fabric_cluster': {'key': 'serviceFabricCluster', 'type': 'BackendServiceFabricClusterProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(BackendProperties, self).__init__(**kwargs) - self.service_fabric_cluster = kwargs.get('service_fabric_cluster', None) - - -class BackendProxyContract(msrest.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. - - :param url: Required. WebProxy Server AbsoluteUri property which includes the entire URI stored - in the Uri instance, including all fragments and query strings. - :type url: str - :param username: Username to connect to the WebProxy server. - :type username: str - :param password: Password to connect to the WebProxy Server. - :type password: str - """ - - _validation = { - 'url': {'required': True, 'max_length': 2000, 'min_length': 1}, - } - - _attribute_map = { - 'url': {'key': 'url', 'type': 'str'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BackendProxyContract, self).__init__(**kwargs) - self.url = kwargs['url'] - self.username = kwargs.get('username', None) - self.password = kwargs.get('password', None) - - -class BackendReconnectContract(Resource): - """Reconnect request parameters. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param after: Duration in ISO8601 format after which reconnect will be initiated. Minimum - duration of the Reconnect is PT2M. - :type after: ~datetime.timedelta - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'after': {'key': 'properties.after', 'type': 'duration'}, - } - - def __init__( - self, - **kwargs - ): - super(BackendReconnectContract, self).__init__(**kwargs) - self.after = kwargs.get('after', None) - - -class BackendServiceFabricClusterProperties(msrest.serialization.Model): - """Properties of the Service Fabric Type Backend. - - All required parameters must be populated in order to send to Azure. - - :param client_certificate_id: The client certificate id for the management endpoint. - :type client_certificate_id: str - :param client_certificatethumbprint: The client certificate thumbprint for the management - endpoint. Will be ignored if certificatesIds are provided. - :type client_certificatethumbprint: str - :param max_partition_resolution_retries: Maximum number of retries while attempting resolve the - partition. - :type max_partition_resolution_retries: int - :param management_endpoints: Required. The cluster management endpoint. - :type management_endpoints: list[str] - :param server_certificate_thumbprints: Thumbprints of certificates cluster management service - uses for tls communication. - :type server_certificate_thumbprints: list[str] - :param server_x509_names: Server X509 Certificate Names Collection. - :type server_x509_names: list[~azure.mgmt.apimanagement.models.X509CertificateName] - """ - - _validation = { - 'management_endpoints': {'required': True}, - } - - _attribute_map = { - 'client_certificate_id': {'key': 'clientCertificateId', 'type': 'str'}, - 'client_certificatethumbprint': {'key': 'clientCertificatethumbprint', 'type': 'str'}, - 'max_partition_resolution_retries': {'key': 'maxPartitionResolutionRetries', 'type': 'int'}, - 'management_endpoints': {'key': 'managementEndpoints', 'type': '[str]'}, - 'server_certificate_thumbprints': {'key': 'serverCertificateThumbprints', 'type': '[str]'}, - 'server_x509_names': {'key': 'serverX509Names', 'type': '[X509CertificateName]'}, - } - - def __init__( - self, - **kwargs - ): - super(BackendServiceFabricClusterProperties, self).__init__(**kwargs) - self.client_certificate_id = kwargs.get('client_certificate_id', None) - self.client_certificatethumbprint = kwargs.get('client_certificatethumbprint', None) - self.max_partition_resolution_retries = kwargs.get('max_partition_resolution_retries', None) - self.management_endpoints = kwargs['management_endpoints'] - self.server_certificate_thumbprints = kwargs.get('server_certificate_thumbprints', None) - self.server_x509_names = kwargs.get('server_x509_names', None) - - -class BackendTlsProperties(msrest.serialization.Model): - """Properties controlling TLS Certificate Validation. - - :param validate_certificate_chain: Flag indicating whether SSL certificate chain validation - should be done when using self-signed certificates for this backend host. - :type validate_certificate_chain: bool - :param validate_certificate_name: Flag indicating whether SSL certificate name validation - should be done when using self-signed certificates for this backend host. - :type validate_certificate_name: bool - """ - - _attribute_map = { - 'validate_certificate_chain': {'key': 'validateCertificateChain', 'type': 'bool'}, - 'validate_certificate_name': {'key': 'validateCertificateName', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(BackendTlsProperties, self).__init__(**kwargs) - self.validate_certificate_chain = kwargs.get('validate_certificate_chain', True) - self.validate_certificate_name = kwargs.get('validate_certificate_name', True) - - -class BackendUpdateParameterProperties(BackendBaseParameters): - """Parameters supplied to the Update Backend operation. - - :param title: Backend Title. - :type title: str - :param description: Backend Description. - :type description: str - :param resource_id: Management Uri of the Resource in External System. This url can be the Arm - Resource Id of Logic Apps, Function Apps or Api Apps. - :type resource_id: str - :param properties: Backend Properties contract. - :type properties: ~azure.mgmt.apimanagement.models.BackendProperties - :param credentials: Backend Credentials Contract Properties. - :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :param proxy: Backend Proxy Contract Properties. - :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract - :param tls: Backend TLS Properties. - :type tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties - :param url: Runtime Url of the Backend. - :type url: str - :param protocol: Backend communication protocol. Possible values include: "http", "soap". - :type protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol - """ - - _validation = { - 'title': {'max_length': 300, 'min_length': 1}, - 'description': {'max_length': 2000, 'min_length': 1}, - 'resource_id': {'max_length': 2000, 'min_length': 1}, - 'url': {'max_length': 2000, 'min_length': 1}, - } - - _attribute_map = { - 'title': {'key': 'title', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'BackendProperties'}, - 'credentials': {'key': 'credentials', 'type': 'BackendCredentialsContract'}, - 'proxy': {'key': 'proxy', 'type': 'BackendProxyContract'}, - 'tls': {'key': 'tls', 'type': 'BackendTlsProperties'}, - 'url': {'key': 'url', 'type': 'str'}, - 'protocol': {'key': 'protocol', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BackendUpdateParameterProperties, self).__init__(**kwargs) - self.url = kwargs.get('url', None) - self.protocol = kwargs.get('protocol', None) - - -class BackendUpdateParameters(msrest.serialization.Model): - """Backend update parameters. - - :param title: Backend Title. - :type title: str - :param description: Backend Description. - :type description: str - :param resource_id: Management Uri of the Resource in External System. This url can be the Arm - Resource Id of Logic Apps, Function Apps or Api Apps. - :type resource_id: str - :param properties: Backend Properties contract. - :type properties: ~azure.mgmt.apimanagement.models.BackendProperties - :param credentials: Backend Credentials Contract Properties. - :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :param proxy: Backend Proxy Contract Properties. - :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract - :param tls: Backend TLS Properties. - :type tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties - :param url: Runtime Url of the Backend. - :type url: str - :param protocol: Backend communication protocol. Possible values include: "http", "soap". - :type protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol - """ - - _validation = { - 'title': {'max_length': 300, 'min_length': 1}, - 'description': {'max_length': 2000, 'min_length': 1}, - 'resource_id': {'max_length': 2000, 'min_length': 1}, - 'url': {'max_length': 2000, 'min_length': 1}, - } - - _attribute_map = { - 'title': {'key': 'properties.title', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, - 'properties': {'key': 'properties.properties', 'type': 'BackendProperties'}, - 'credentials': {'key': 'properties.credentials', 'type': 'BackendCredentialsContract'}, - 'proxy': {'key': 'properties.proxy', 'type': 'BackendProxyContract'}, - 'tls': {'key': 'properties.tls', 'type': 'BackendTlsProperties'}, - 'url': {'key': 'properties.url', 'type': 'str'}, - 'protocol': {'key': 'properties.protocol', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BackendUpdateParameters, self).__init__(**kwargs) - self.title = kwargs.get('title', None) - self.description = kwargs.get('description', None) - self.resource_id = kwargs.get('resource_id', None) - self.properties = kwargs.get('properties', None) - self.credentials = kwargs.get('credentials', None) - self.proxy = kwargs.get('proxy', None) - self.tls = kwargs.get('tls', None) - self.url = kwargs.get('url', None) - self.protocol = kwargs.get('protocol', None) - - -class BodyDiagnosticSettings(msrest.serialization.Model): - """Body logging settings. - - :param bytes: Number of request body bytes to log. - :type bytes: int - """ - - _validation = { - 'bytes': {'maximum': 8192}, - } - - _attribute_map = { - 'bytes': {'key': 'bytes', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(BodyDiagnosticSettings, self).__init__(**kwargs) - self.bytes = kwargs.get('bytes', None) - - -class CacheCollection(msrest.serialization.Model): - """Paged Caches list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.CacheContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CacheContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CacheCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class CacheContract(Resource): - """Cache details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param description: Cache description. - :type description: str - :param connection_string: Runtime connection string to cache. - :type connection_string: str - :param use_from_location: Location identifier to use cache from (should be either 'default' or - valid Azure region identifier). - :type use_from_location: str - :param resource_id: Original uri of entity in external system cache points to. - :type resource_id: str - """ - - _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}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, - 'use_from_location': {'key': 'properties.useFromLocation', 'type': 'str'}, - 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CacheContract, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.connection_string = kwargs.get('connection_string', None) - self.use_from_location = kwargs.get('use_from_location', None) - self.resource_id = kwargs.get('resource_id', None) - - -class CacheUpdateParameters(msrest.serialization.Model): - """Cache update details. - - :param description: Cache description. - :type description: str - :param connection_string: Runtime connection string to cache. - :type connection_string: str - :param use_from_location: Location identifier to use cache from (should be either 'default' or - valid Azure region identifier). - :type use_from_location: str - :param resource_id: Original uri of entity in external system cache points to. - :type resource_id: str - """ - - _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}, - } - - _attribute_map = { - 'description': {'key': 'properties.description', 'type': 'str'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, - 'use_from_location': {'key': 'properties.useFromLocation', 'type': 'str'}, - 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CacheUpdateParameters, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.connection_string = kwargs.get('connection_string', None) - self.use_from_location = kwargs.get('use_from_location', None) - self.resource_id = kwargs.get('resource_id', None) - - -class CertificateCollection(msrest.serialization.Model): - """Paged Certificates list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.CertificateContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class CertificateConfiguration(msrest.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. - - :param encoded_certificate: Base64 Encoded certificate. - :type encoded_certificate: str - :param certificate_password: Certificate Password. - :type certificate_password: str - :param store_name: Required. The System.Security.Cryptography.x509certificates.StoreName - certificate store location. Only Root and CertificateAuthority are valid locations. Possible - values include: "CertificateAuthority", "Root". - :type store_name: str or ~azure.mgmt.apimanagement.models.CertificateConfigurationStoreName - :param certificate: Certificate information. - :type certificate: ~azure.mgmt.apimanagement.models.CertificateInformation - """ - - _validation = { - 'store_name': {'required': True}, - } - - _attribute_map = { - 'encoded_certificate': {'key': 'encodedCertificate', 'type': 'str'}, - 'certificate_password': {'key': 'certificatePassword', 'type': 'str'}, - 'store_name': {'key': 'storeName', 'type': 'str'}, - 'certificate': {'key': 'certificate', 'type': 'CertificateInformation'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateConfiguration, self).__init__(**kwargs) - self.encoded_certificate = kwargs.get('encoded_certificate', None) - self.certificate_password = kwargs.get('certificate_password', None) - self.store_name = kwargs['store_name'] - self.certificate = kwargs.get('certificate', None) - - -class CertificateContract(Resource): - """Certificate details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param subject: Subject attribute of the certificate. - :type subject: str - :param thumbprint: Thumbprint of the certificate. - :type thumbprint: str - :param expiration_date: Expiration date of the certificate. The date conforms to the following - format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type expiration_date: ~datetime.datetime - :param key_vault: KeyVault location details of the certificate. - :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'subject': {'key': 'properties.subject', 'type': 'str'}, - 'thumbprint': {'key': 'properties.thumbprint', 'type': 'str'}, - 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, - 'key_vault': {'key': 'properties.keyVault', 'type': 'KeyVaultContractProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateContract, self).__init__(**kwargs) - self.subject = kwargs.get('subject', None) - self.thumbprint = kwargs.get('thumbprint', None) - self.expiration_date = kwargs.get('expiration_date', None) - self.key_vault = kwargs.get('key_vault', None) - - -class CertificateCreateOrUpdateParameters(msrest.serialization.Model): - """Certificate create or update details. - - :param data: Base 64 encoded certificate using the application/x-pkcs12 representation. - :type data: str - :param password: Password for the Certificate. - :type password: str - :param key_vault: KeyVault location details of the certificate. - :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties - """ - - _attribute_map = { - 'data': {'key': 'properties.data', 'type': 'str'}, - 'password': {'key': 'properties.password', 'type': 'str'}, - 'key_vault': {'key': 'properties.keyVault', 'type': 'KeyVaultContractCreateProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateCreateOrUpdateParameters, self).__init__(**kwargs) - self.data = kwargs.get('data', None) - self.password = kwargs.get('password', None) - self.key_vault = kwargs.get('key_vault', None) - - -class CertificateInformation(msrest.serialization.Model): - """SSL certificate information. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type expiry: ~datetime.datetime - :param thumbprint: Required. Thumbprint of the certificate. - :type thumbprint: str - :param subject: Required. Subject of the certificate. - :type subject: str - """ - - _validation = { - 'expiry': {'required': True}, - 'thumbprint': {'required': True}, - 'subject': {'required': True}, - } - - _attribute_map = { - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'subject': {'key': 'subject', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateInformation, self).__init__(**kwargs) - self.expiry = kwargs['expiry'] - self.thumbprint = kwargs['thumbprint'] - self.subject = kwargs['subject'] - - -class ClientSecretContract(msrest.serialization.Model): - """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. - - :param client_secret: Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. - :type client_secret: str - """ - - _attribute_map = { - 'client_secret': {'key': 'clientSecret', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClientSecretContract, self).__init__(**kwargs) - self.client_secret = kwargs.get('client_secret', None) - - -class ConnectivityStatusContract(msrest.serialization.Model): - """Details about connectivity to a resource. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type name: str - :param status: Required. Resource Connectivity Status Type identifier. Possible values include: - "initializing", "success", "failure". - :type status: str or ~azure.mgmt.apimanagement.models.ConnectivityStatusType - :param error: Error details of the connectivity to the resource. - :type error: str - :param 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. - :type last_updated: ~datetime.datetime - :param 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. - :type last_status_change: ~datetime.datetime - :param resource_type: Required. Resource Type. - :type resource_type: str - :param is_optional: Required. Whether this is optional. - :type is_optional: bool - """ - - _validation = { - 'name': {'required': True, 'min_length': 1}, - 'status': {'required': True}, - 'last_updated': {'required': True}, - 'last_status_change': {'required': True}, - 'resource_type': {'required': True}, - 'is_optional': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'str'}, - 'last_updated': {'key': 'lastUpdated', 'type': 'iso-8601'}, - 'last_status_change': {'key': 'lastStatusChange', 'type': 'iso-8601'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'is_optional': {'key': 'isOptional', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectivityStatusContract, self).__init__(**kwargs) - self.name = kwargs['name'] - self.status = kwargs['status'] - self.error = kwargs.get('error', None) - self.last_updated = kwargs['last_updated'] - self.last_status_change = kwargs['last_status_change'] - self.resource_type = kwargs['resource_type'] - self.is_optional = kwargs['is_optional'] - - -class ContentItemCollection(msrest.serialization.Model): - """Paged list of content items. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Collection of content items. - :vartype value: list[~azure.mgmt.apimanagement.models.ContentItemContract] - :ivar next_link: Next page link, if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ContentItemContract]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ContentItemCollection, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ContentItemContract(Resource): - """Content type contract details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param properties: Properties of the content item. - :type properties: dict[str, any] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{object}'}, - } - - def __init__( - self, - **kwargs - ): - super(ContentItemContract, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class ContentTypeCollection(msrest.serialization.Model): - """Paged list of content types. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Collection of content types. - :vartype value: list[~azure.mgmt.apimanagement.models.ContentTypeContract] - :ivar next_link: Next page link, if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ContentTypeContract]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ContentTypeCollection, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ContentTypeContract(Resource): - """Content type contract details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param id_properties_id: Content type identifier. - :type id_properties_id: str - :param name_properties_name: Content type name. Must be 1 to 250 characters long. - :type name_properties_name: str - :param description: Content type description. - :type description: str - :param schema: Content type schema. - :type schema: any - :param version: Content type version. - :type version: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'id_properties_id': {'key': 'properties.id', 'type': 'str'}, - 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'schema': {'key': 'properties.schema', 'type': 'object'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ContentTypeContract, self).__init__(**kwargs) - self.id_properties_id = kwargs.get('id_properties_id', None) - self.name_properties_name = kwargs.get('name_properties_name', None) - self.description = kwargs.get('description', None) - self.schema = kwargs.get('schema', None) - self.version = kwargs.get('version', None) - - -class DataMasking(msrest.serialization.Model): - """DataMasking. - - :param query_params: Masking settings for Url query parameters. - :type query_params: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] - :param headers: Masking settings for headers. - :type headers: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] - """ - - _attribute_map = { - 'query_params': {'key': 'queryParams', 'type': '[DataMaskingEntity]'}, - 'headers': {'key': 'headers', 'type': '[DataMaskingEntity]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataMasking, self).__init__(**kwargs) - self.query_params = kwargs.get('query_params', None) - self.headers = kwargs.get('headers', None) - - -class DataMaskingEntity(msrest.serialization.Model): - """DataMaskingEntity. - - :param value: The name of an entity to mask (e.g. a name of a header or a query parameter). - :type value: str - :param mode: Data masking mode. Possible values include: "Mask", "Hide". - :type mode: str or ~azure.mgmt.apimanagement.models.DataMaskingMode - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'mode': {'key': 'mode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataMaskingEntity, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.mode = kwargs.get('mode', None) - - -class DeletedServiceContract(Resource): - """Deleted Api Management Service information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :ivar location: Api Management Service Master Location. - :vartype location: str - :param service_id: Fully-qualified API Management Service Resource ID. - :type service_id: str - :param scheduled_purge_date: UTC Date and Time when the service will be automatically purged. - The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 - standard. - :type scheduled_purge_date: ~datetime.datetime - :param deletion_date: UTC Timestamp when the service was soft-deleted. The date conforms to the - following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. - :type deletion_date: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'service_id': {'key': 'properties.serviceId', 'type': 'str'}, - 'scheduled_purge_date': {'key': 'properties.scheduledPurgeDate', 'type': 'iso-8601'}, - 'deletion_date': {'key': 'properties.deletionDate', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(DeletedServiceContract, self).__init__(**kwargs) - self.location = None - self.service_id = kwargs.get('service_id', None) - self.scheduled_purge_date = kwargs.get('scheduled_purge_date', None) - self.deletion_date = kwargs.get('deletion_date', None) - - -class DeletedServicesCollection(msrest.serialization.Model): - """Paged deleted Api Management Services List Representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.DeletedServiceContract] - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DeletedServiceContract]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DeletedServicesCollection, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DeployConfigurationParameters(msrest.serialization.Model): - """Deploy Tenant Configuration Contract. - - :param branch: The name of the Git branch from which the configuration is to be deployed to the - configuration database. - :type branch: str - :param force: The value enforcing deleting subscriptions to products that are deleted in this - update. - :type force: bool - """ - - _attribute_map = { - 'branch': {'key': 'properties.branch', 'type': 'str'}, - 'force': {'key': 'properties.force', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(DeployConfigurationParameters, self).__init__(**kwargs) - self.branch = kwargs.get('branch', None) - self.force = kwargs.get('force', None) - - -class DiagnosticCollection(msrest.serialization.Model): - """Paged Diagnostic list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.DiagnosticContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DiagnosticContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DiagnosticCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class DiagnosticContract(Resource): - """Diagnostic details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param always_log: Specifies for what type of messages sampling settings should not apply. - Possible values include: "allErrors". - :type always_log: str or ~azure.mgmt.apimanagement.models.AlwaysLog - :param logger_id: Resource Id of a target logger. - :type logger_id: str - :param sampling: Sampling settings for Diagnostic. - :type sampling: ~azure.mgmt.apimanagement.models.SamplingSettings - :param frontend: Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. - :type frontend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings - :param backend: Diagnostic settings for incoming/outgoing HTTP messages to the Backend. - :type backend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings - :param log_client_ip: Log the ClientIP. Default is false. - :type log_client_ip: bool - :param http_correlation_protocol: Sets correlation protocol to use for Application Insights - diagnostics. Possible values include: "None", "Legacy", "W3C". - :type http_correlation_protocol: str or - ~azure.mgmt.apimanagement.models.HttpCorrelationProtocol - :param verbosity: The verbosity level applied to traces emitted by trace policies. Possible - values include: "verbose", "information", "error". - :type verbosity: str or ~azure.mgmt.apimanagement.models.Verbosity - :param operation_name_format: The format of the Operation Name for Application Insights - telemetries. Default is Name. Possible values include: "Name", "Url". - :type operation_name_format: str or ~azure.mgmt.apimanagement.models.OperationNameFormat - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'always_log': {'key': 'properties.alwaysLog', 'type': 'str'}, - 'logger_id': {'key': 'properties.loggerId', 'type': 'str'}, - 'sampling': {'key': 'properties.sampling', 'type': 'SamplingSettings'}, - 'frontend': {'key': 'properties.frontend', 'type': 'PipelineDiagnosticSettings'}, - 'backend': {'key': 'properties.backend', 'type': 'PipelineDiagnosticSettings'}, - 'log_client_ip': {'key': 'properties.logClientIp', 'type': 'bool'}, - 'http_correlation_protocol': {'key': 'properties.httpCorrelationProtocol', 'type': 'str'}, - 'verbosity': {'key': 'properties.verbosity', 'type': 'str'}, - 'operation_name_format': {'key': 'properties.operationNameFormat', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DiagnosticContract, self).__init__(**kwargs) - self.always_log = kwargs.get('always_log', None) - self.logger_id = kwargs.get('logger_id', None) - self.sampling = kwargs.get('sampling', None) - self.frontend = kwargs.get('frontend', None) - self.backend = kwargs.get('backend', None) - self.log_client_ip = kwargs.get('log_client_ip', None) - self.http_correlation_protocol = kwargs.get('http_correlation_protocol', None) - self.verbosity = kwargs.get('verbosity', None) - self.operation_name_format = kwargs.get('operation_name_format', None) - - -class EmailTemplateCollection(msrest.serialization.Model): - """Paged email template list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.EmailTemplateContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[EmailTemplateContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EmailTemplateCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class EmailTemplateContract(Resource): - """Email Template details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param subject: Subject of the Template. - :type subject: str - :param body: Email Template Body. This should be a valid XDocument. - :type body: str - :param title: Title of the Template. - :type title: str - :param description: Description of the Email Template. - :type description: str - :ivar is_default: Whether the template is the default template provided by Api Management or - has been edited. - :vartype is_default: bool - :param parameters: Email Template Parameter values. - :type parameters: - list[~azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'subject': {'max_length': 1000, 'min_length': 1}, - 'body': {'min_length': 1}, - 'is_default': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'subject': {'key': 'properties.subject', 'type': 'str'}, - 'body': {'key': 'properties.body', 'type': 'str'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'is_default': {'key': 'properties.isDefault', 'type': 'bool'}, - 'parameters': {'key': 'properties.parameters', 'type': '[EmailTemplateParametersContractProperties]'}, - } - - def __init__( - self, - **kwargs - ): - super(EmailTemplateContract, self).__init__(**kwargs) - self.subject = kwargs.get('subject', None) - self.body = kwargs.get('body', None) - self.title = kwargs.get('title', None) - self.description = kwargs.get('description', None) - self.is_default = None - self.parameters = kwargs.get('parameters', None) - - -class EmailTemplateParametersContractProperties(msrest.serialization.Model): - """Email Template Parameter contract. - - :param name: Template parameter name. - :type name: str - :param title: Template parameter title. - :type title: str - :param description: Template parameter description. - :type description: str - """ - - _validation = { - 'name': {'max_length': 256, 'min_length': 1, 'pattern': r'^[A-Za-z0-9-._]+$'}, - 'title': {'max_length': 4096, 'min_length': 1}, - 'description': {'max_length': 256, 'min_length': 1, 'pattern': r'^[A-Za-z0-9-._]+$'}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'title': {'key': 'title', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EmailTemplateParametersContractProperties, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.title = kwargs.get('title', None) - self.description = kwargs.get('description', None) - - -class EmailTemplateUpdateParameters(msrest.serialization.Model): - """Email Template update Parameters. - - :param subject: Subject of the Template. - :type subject: str - :param title: Title of the Template. - :type title: str - :param description: Description of the Email Template. - :type description: str - :param body: Email Template Body. This should be a valid XDocument. - :type body: str - :param parameters: Email Template Parameter values. - :type parameters: - list[~azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties] - """ - - _validation = { - 'subject': {'max_length': 1000, 'min_length': 1}, - 'body': {'min_length': 1}, - } - - _attribute_map = { - 'subject': {'key': 'properties.subject', 'type': 'str'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'body': {'key': 'properties.body', 'type': 'str'}, - 'parameters': {'key': 'properties.parameters', 'type': '[EmailTemplateParametersContractProperties]'}, - } - - def __init__( - self, - **kwargs - ): - super(EmailTemplateUpdateParameters, self).__init__(**kwargs) - self.subject = kwargs.get('subject', None) - self.title = kwargs.get('title', None) - self.description = kwargs.get('description', None) - self.body = kwargs.get('body', None) - self.parameters = kwargs.get('parameters', None) - - -class ErrorFieldContract(msrest.serialization.Model): - """Error Field contract. - - :param code: Property level error code. - :type code: str - :param message: Human-readable representation of property-level error. - :type message: str - :param target: Property name. - :type target: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorFieldContract, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - - -class ErrorResponse(msrest.serialization.Model): - """Error Response. - - :param code: Service-defined error code. This code serves as a sub-status for the HTTP error - code specified in the response. - :type code: str - :param message: Human-readable representation of the error. - :type message: str - :param details: The list of invalid fields send in request, in case of validation error. - :type 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]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = kwargs.get('details', None) - - -class ErrorResponseBody(msrest.serialization.Model): - """Error Body contract. - - :param code: Service-defined error code. This code serves as a sub-status for the HTTP error - code specified in the response. - :type code: str - :param message: Human-readable representation of the error. - :type message: str - :param details: The list of invalid fields send in request, in case of validation error. - :type details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorFieldContract]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = kwargs.get('details', None) - - -class GatewayCertificateAuthorityCollection(msrest.serialization.Model): - """Paged Gateway certificate authority list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract] - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[GatewayCertificateAuthorityContract]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GatewayCertificateAuthorityCollection, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class GatewayCertificateAuthorityContract(Resource): - """Gateway certificate authority details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param is_trusted: Determines whether certificate authority is trusted. - :type is_trusted: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'is_trusted': {'key': 'properties.isTrusted', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(GatewayCertificateAuthorityContract, self).__init__(**kwargs) - self.is_trusted = kwargs.get('is_trusted', None) - - -class GatewayCollection(msrest.serialization.Model): - """Paged Gateway list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.GatewayContract] - :param count: Total record count number across all pages. - :type count: long - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[GatewayContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GatewayCollection, self).__init__(**kwargs) - self.value = None - self.count = kwargs.get('count', None) - self.next_link = None - - -class GatewayContract(Resource): - """Gateway details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param location_data: Gateway location. - :type location_data: ~azure.mgmt.apimanagement.models.ResourceLocationDataContract - :param description: Gateway description. - :type description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'description': {'max_length': 1000, 'min_length': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location_data': {'key': 'properties.locationData', 'type': 'ResourceLocationDataContract'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GatewayContract, self).__init__(**kwargs) - self.location_data = kwargs.get('location_data', None) - self.description = kwargs.get('description', None) - - -class GatewayHostnameConfigurationCollection(msrest.serialization.Model): - """Paged Gateway hostname configuration list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract] - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[GatewayHostnameConfigurationContract]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GatewayHostnameConfigurationCollection, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class GatewayHostnameConfigurationContract(Resource): - """Gateway hostname configuration details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param hostname: Hostname value. Supports valid domain name, partial or full wildcard. - :type hostname: str - :param certificate_id: Identifier of Certificate entity that will be used for TLS connection - establishment. - :type certificate_id: str - :param negotiate_client_certificate: Determines whether gateway requests client certificate. - :type negotiate_client_certificate: bool - :param tls10_enabled: Specifies if TLS 1.0 is supported. - :type tls10_enabled: bool - :param tls11_enabled: Specifies if TLS 1.1 is supported. - :type tls11_enabled: bool - :param http2_enabled: Specifies if HTTP/2.0 is supported. - :type http2_enabled: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'hostname': {'key': 'properties.hostname', 'type': 'str'}, - 'certificate_id': {'key': 'properties.certificateId', 'type': 'str'}, - 'negotiate_client_certificate': {'key': 'properties.negotiateClientCertificate', 'type': 'bool'}, - 'tls10_enabled': {'key': 'properties.tls10Enabled', 'type': 'bool'}, - 'tls11_enabled': {'key': 'properties.tls11Enabled', 'type': 'bool'}, - 'http2_enabled': {'key': 'properties.http2Enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(GatewayHostnameConfigurationContract, self).__init__(**kwargs) - self.hostname = kwargs.get('hostname', None) - self.certificate_id = kwargs.get('certificate_id', None) - self.negotiate_client_certificate = kwargs.get('negotiate_client_certificate', None) - self.tls10_enabled = kwargs.get('tls10_enabled', None) - self.tls11_enabled = kwargs.get('tls11_enabled', None) - self.http2_enabled = kwargs.get('http2_enabled', None) - - -class GatewayKeyRegenerationRequestContract(msrest.serialization.Model): - """Gateway key regeneration request contract properties. - - All required parameters must be populated in order to send to Azure. - - :param key_type: Required. The Key being regenerated. Possible values include: "primary", - "secondary". - :type key_type: str or ~azure.mgmt.apimanagement.models.KeyType - """ - - _validation = { - 'key_type': {'required': True}, - } - - _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GatewayKeyRegenerationRequestContract, self).__init__(**kwargs) - self.key_type = kwargs['key_type'] - - -class GatewayKeysContract(msrest.serialization.Model): - """Gateway authentication keys. - - :param primary: Primary gateway key. - :type primary: str - :param secondary: Secondary gateway key. - :type secondary: str - """ - - _attribute_map = { - 'primary': {'key': 'primary', 'type': 'str'}, - 'secondary': {'key': 'secondary', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GatewayKeysContract, self).__init__(**kwargs) - self.primary = kwargs.get('primary', None) - self.secondary = kwargs.get('secondary', None) - - -class GatewayTokenContract(msrest.serialization.Model): - """Gateway access token. - - :param value: Shared Access Authentication token value for the Gateway. - :type value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GatewayTokenContract, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class GatewayTokenRequestContract(msrest.serialization.Model): - """Gateway token request contract properties. - - All required parameters must be populated in order to send to Azure. - - :param key_type: Required. The Key to be used to generate gateway token. Possible values - include: "primary", "secondary". - :type key_type: str or ~azure.mgmt.apimanagement.models.KeyType - :param 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. - :type expiry: ~datetime.datetime - """ - - _validation = { - 'key_type': {'required': True}, - 'expiry': {'required': True}, - } - - _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(GatewayTokenRequestContract, self).__init__(**kwargs) - self.key_type = kwargs['key_type'] - self.expiry = kwargs['expiry'] - - -class GenerateSsoUrlResult(msrest.serialization.Model): - """Generate SSO Url operations response details. - - :param value: Redirect Url containing the SSO URL value. - :type value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GenerateSsoUrlResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class GroupCollection(msrest.serialization.Model): - """Paged Group list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.GroupContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[GroupContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GroupCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class GroupContract(Resource): - """Contract details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param display_name: Group name. - :type display_name: str - :param description: Group description. Can contain HTML formatting tags. - :type 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 - :param type_properties_type: Group type. Possible values include: "custom", "system", - "external". - :type type_properties_type: str or ~azure.mgmt.apimanagement.models.GroupType - :param 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. - :type external_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'max_length': 300, 'min_length': 1}, - 'description': {'max_length': 1000, 'min_length': 0}, - 'built_in': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'built_in': {'key': 'properties.builtIn', 'type': 'bool'}, - 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, - 'external_id': {'key': 'properties.externalId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GroupContract, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.description = kwargs.get('description', None) - self.built_in = None - self.type_properties_type = kwargs.get('type_properties_type', None) - self.external_id = kwargs.get('external_id', None) - - -class GroupContractProperties(msrest.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. - - :param display_name: Required. Group name. - :type display_name: str - :param description: Group description. Can contain HTML formatting tags. - :type 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 - :param type: Group type. Possible values include: "custom", "system", "external". - :type type: str or ~azure.mgmt.apimanagement.models.GroupType - :param 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. - :type external_id: str - """ - - _validation = { - 'display_name': {'required': True, 'max_length': 300, 'min_length': 1}, - 'description': {'max_length': 1000, 'min_length': 0}, - 'built_in': {'readonly': True}, - } - - _attribute_map = { - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'built_in': {'key': 'builtIn', 'type': 'bool'}, - 'type': {'key': 'type', 'type': 'str'}, - 'external_id': {'key': 'externalId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GroupContractProperties, self).__init__(**kwargs) - self.display_name = kwargs['display_name'] - self.description = kwargs.get('description', None) - self.built_in = None - self.type = kwargs.get('type', None) - self.external_id = kwargs.get('external_id', None) - - -class GroupCreateParameters(msrest.serialization.Model): - """Parameters supplied to the Create Group operation. - - :param display_name: Group name. - :type display_name: str - :param description: Group description. - :type description: str - :param type: Group type. Possible values include: "custom", "system", "external". - :type type: str or ~azure.mgmt.apimanagement.models.GroupType - :param 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. - :type external_id: str - """ - - _validation = { - 'display_name': {'max_length': 300, 'min_length': 1}, - } - - _attribute_map = { - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'type': {'key': 'properties.type', 'type': 'str'}, - 'external_id': {'key': 'properties.externalId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GroupCreateParameters, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.description = kwargs.get('description', None) - self.type = kwargs.get('type', None) - self.external_id = kwargs.get('external_id', None) - - -class GroupUpdateParameters(msrest.serialization.Model): - """Parameters supplied to the Update Group operation. - - :param display_name: Group name. - :type display_name: str - :param description: Group description. - :type description: str - :param type: Group type. Possible values include: "custom", "system", "external". - :type type: str or ~azure.mgmt.apimanagement.models.GroupType - :param 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. - :type external_id: str - """ - - _validation = { - 'display_name': {'max_length': 300, 'min_length': 1}, - } - - _attribute_map = { - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'type': {'key': 'properties.type', 'type': 'str'}, - 'external_id': {'key': 'properties.externalId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GroupUpdateParameters, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.description = kwargs.get('description', None) - self.type = kwargs.get('type', None) - self.external_id = kwargs.get('external_id', None) - - -class HostnameConfiguration(msrest.serialization.Model): - """Custom hostname configuration. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. Hostname type. Possible values include: "Proxy", "Portal", "Management", - "Scm", "DeveloperPortal". - :type type: str or ~azure.mgmt.apimanagement.models.HostnameType - :param host_name: Required. Hostname to configure on the Api Management service. - :type host_name: str - :param key_vault_id: Url to the KeyVault Secret containing the Ssl Certificate. If absolute Url - containing version is provided, auto-update of ssl certificate will not work. This requires Api - Management service to be configured with aka.ms/apimmsi. The secret should be of type - *application/x-pkcs12*. - :type key_vault_id: str - :param identity_client_id: System or User Assigned Managed identity clientId as generated by - Azure AD, which has GET access to the keyVault containing the SSL certificate. - :type identity_client_id: str - :param encoded_certificate: Base64 Encoded certificate. - :type encoded_certificate: str - :param certificate_password: Certificate Password. - :type certificate_password: str - :param default_ssl_binding: Specify true to setup the certificate associated with this Hostname - as the Default SSL Certificate. If a client does not send the SNI header, then this will be the - certificate that will be challenged. The property is useful if a service has multiple custom - hostname enabled and it needs to decide on the default ssl certificate. The setting only - applied to Proxy Hostname Type. - :type default_ssl_binding: bool - :param negotiate_client_certificate: Specify true to always negotiate client certificate on the - hostname. Default Value is false. - :type negotiate_client_certificate: bool - :param certificate: Certificate information. - :type certificate: ~azure.mgmt.apimanagement.models.CertificateInformation - """ - - _validation = { - 'type': {'required': True}, - 'host_name': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'host_name': {'key': 'hostName', 'type': 'str'}, - 'key_vault_id': {'key': 'keyVaultId', 'type': 'str'}, - 'identity_client_id': {'key': 'identityClientId', 'type': 'str'}, - 'encoded_certificate': {'key': 'encodedCertificate', 'type': 'str'}, - 'certificate_password': {'key': 'certificatePassword', 'type': 'str'}, - 'default_ssl_binding': {'key': 'defaultSslBinding', 'type': 'bool'}, - 'negotiate_client_certificate': {'key': 'negotiateClientCertificate', 'type': 'bool'}, - 'certificate': {'key': 'certificate', 'type': 'CertificateInformation'}, - } - - def __init__( - self, - **kwargs - ): - super(HostnameConfiguration, self).__init__(**kwargs) - self.type = kwargs['type'] - self.host_name = kwargs['host_name'] - self.key_vault_id = kwargs.get('key_vault_id', None) - self.identity_client_id = kwargs.get('identity_client_id', None) - self.encoded_certificate = kwargs.get('encoded_certificate', None) - self.certificate_password = kwargs.get('certificate_password', None) - self.default_ssl_binding = kwargs.get('default_ssl_binding', False) - self.negotiate_client_certificate = kwargs.get('negotiate_client_certificate', False) - self.certificate = kwargs.get('certificate', None) - - -class HttpMessageDiagnostic(msrest.serialization.Model): - """Http message diagnostic settings. - - :param headers: Array of HTTP Headers to log. - :type headers: list[str] - :param body: Body logging settings. - :type body: ~azure.mgmt.apimanagement.models.BodyDiagnosticSettings - :param data_masking: Data masking settings. - :type data_masking: ~azure.mgmt.apimanagement.models.DataMasking - """ - - _attribute_map = { - 'headers': {'key': 'headers', 'type': '[str]'}, - 'body': {'key': 'body', 'type': 'BodyDiagnosticSettings'}, - 'data_masking': {'key': 'dataMasking', 'type': 'DataMasking'}, - } - - def __init__( - self, - **kwargs - ): - super(HttpMessageDiagnostic, self).__init__(**kwargs) - self.headers = kwargs.get('headers', None) - self.body = kwargs.get('body', None) - self.data_masking = kwargs.get('data_masking', None) - - -class IdentityProviderBaseParameters(msrest.serialization.Model): - """Identity Provider Base Parameter Properties. - - :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", - "microsoft", "twitter", "aad", "aadB2C". - :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity - Provider. - :type password_reset_policy_name: 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}, - } - - _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'}, - } - - def __init__( - self, - **kwargs - ): - super(IdentityProviderBaseParameters, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.signin_tenant = kwargs.get('signin_tenant', None) - self.allowed_tenants = kwargs.get('allowed_tenants', None) - self.authority = kwargs.get('authority', None) - self.signup_policy_name = kwargs.get('signup_policy_name', None) - self.signin_policy_name = kwargs.get('signin_policy_name', None) - self.profile_editing_policy_name = kwargs.get('profile_editing_policy_name', None) - self.password_reset_policy_name = kwargs.get('password_reset_policy_name', None) - - -class IdentityProviderContract(Resource): - """Identity Provider details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param type_properties_type: Identity Provider Type identifier. Possible values include: - "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :type type_properties_type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity - Provider. - :type password_reset_policy_name: str - :param 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. - :type client_id: str - :param 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. - :type client_secret: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'allowed_tenants': {'max_items': 32, 'min_items': 0}, - 'signup_policy_name': {'min_length': 1}, - 'signin_policy_name': {'min_length': 1}, - 'profile_editing_policy_name': {'min_length': 1}, - 'password_reset_policy_name': {'min_length': 1}, - 'client_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, - **kwargs - ): - super(IdentityProviderContract, self).__init__(**kwargs) - self.type_properties_type = kwargs.get('type_properties_type', None) - self.signin_tenant = kwargs.get('signin_tenant', None) - self.allowed_tenants = kwargs.get('allowed_tenants', None) - self.authority = kwargs.get('authority', None) - self.signup_policy_name = kwargs.get('signup_policy_name', None) - self.signin_policy_name = kwargs.get('signin_policy_name', None) - self.profile_editing_policy_name = kwargs.get('profile_editing_policy_name', None) - self.password_reset_policy_name = kwargs.get('password_reset_policy_name', None) - self.client_id = kwargs.get('client_id', None) - self.client_secret = kwargs.get('client_secret', None) - - -class IdentityProviderContractProperties(IdentityProviderBaseParameters): - """The external Identity Providers like Facebook, Google, Microsoft, Twitter or Azure Active Directory which can be used to enable access to the API Management service developer portal for all users. - - All required parameters must be populated in order to send to Azure. - - :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", - "microsoft", "twitter", "aad", "aadB2C". - :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity - Provider. - :type password_reset_policy_name: str - :param 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. - :type client_id: str - :param 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. - :type 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': {'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'}, - } - - def __init__( - self, - **kwargs - ): - super(IdentityProviderContractProperties, self).__init__(**kwargs) - self.client_id = kwargs['client_id'] - self.client_secret = kwargs.get('client_secret', None) - - -class IdentityProviderCreateContract(Resource): - """Identity Provider details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param type_properties_type: Identity Provider Type identifier. Possible values include: - "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :type type_properties_type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity - Provider. - :type password_reset_policy_name: str - :param 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. - :type client_id: str - :param 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. - :type client_secret: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'allowed_tenants': {'max_items': 32, 'min_items': 0}, - 'signup_policy_name': {'min_length': 1}, - 'signin_policy_name': {'min_length': 1}, - 'profile_editing_policy_name': {'min_length': 1}, - 'password_reset_policy_name': {'min_length': 1}, - 'client_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, - **kwargs - ): - super(IdentityProviderCreateContract, self).__init__(**kwargs) - self.type_properties_type = kwargs.get('type_properties_type', None) - self.signin_tenant = kwargs.get('signin_tenant', None) - self.allowed_tenants = kwargs.get('allowed_tenants', None) - self.authority = kwargs.get('authority', None) - self.signup_policy_name = kwargs.get('signup_policy_name', None) - self.signin_policy_name = kwargs.get('signin_policy_name', None) - self.profile_editing_policy_name = kwargs.get('profile_editing_policy_name', None) - self.password_reset_policy_name = kwargs.get('password_reset_policy_name', None) - self.client_id = kwargs.get('client_id', None) - self.client_secret = kwargs.get('client_secret', None) - - -class IdentityProviderCreateContractProperties(IdentityProviderBaseParameters): - """The external Identity Providers like Facebook, Google, Microsoft, Twitter or Azure Active Directory which can be used to enable access to the API Management service developer portal for all users. - - All required parameters must be populated in order to send to Azure. - - :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", - "microsoft", "twitter", "aad", "aadB2C". - :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity - Provider. - :type password_reset_policy_name: str - :param 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. - :type client_id: str - :param 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. - :type 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}, - } - - _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'}, - } - - def __init__( - self, - **kwargs - ): - super(IdentityProviderCreateContractProperties, self).__init__(**kwargs) - self.client_id = kwargs['client_id'] - self.client_secret = kwargs['client_secret'] - - -class IdentityProviderList(msrest.serialization.Model): - """List of all the Identity Providers configured on the service instance. - - :param value: Identity Provider configuration values. - :type value: list[~azure.mgmt.apimanagement.models.IdentityProviderContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[IdentityProviderContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IdentityProviderList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class IdentityProviderUpdateParameters(msrest.serialization.Model): - """Parameters supplied to update Identity Provider. - - :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", - "microsoft", "twitter", "aad", "aadB2C". - :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity - Provider. - :type password_reset_policy_name: str - :param 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. - :type client_id: str - :param 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. - :type 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': {'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'}, - } - - def __init__( - self, - **kwargs - ): - super(IdentityProviderUpdateParameters, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.signin_tenant = kwargs.get('signin_tenant', None) - self.allowed_tenants = kwargs.get('allowed_tenants', None) - self.authority = kwargs.get('authority', None) - self.signup_policy_name = kwargs.get('signup_policy_name', None) - self.signin_policy_name = kwargs.get('signin_policy_name', None) - self.profile_editing_policy_name = kwargs.get('profile_editing_policy_name', None) - self.password_reset_policy_name = kwargs.get('password_reset_policy_name', None) - self.client_id = kwargs.get('client_id', None) - self.client_secret = kwargs.get('client_secret', None) - - -class IdentityProviderUpdateProperties(IdentityProviderBaseParameters): - """Parameters supplied to the Update Identity Provider operation. - - :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", - "microsoft", "twitter", "aad", "aadB2C". - :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity - Provider. - :type password_reset_policy_name: str - :param 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. - :type client_id: str - :param 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. - :type 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': {'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'}, - } - - def __init__( - self, - **kwargs - ): - super(IdentityProviderUpdateProperties, self).__init__(**kwargs) - self.client_id = kwargs.get('client_id', None) - self.client_secret = kwargs.get('client_secret', None) - - -class IssueAttachmentCollection(msrest.serialization.Model): - """Paged Issue Attachment list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Issue Attachment values. - :vartype value: list[~azure.mgmt.apimanagement.models.IssueAttachmentContract] - :param count: Total record count number across all pages. - :type count: long - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[IssueAttachmentContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IssueAttachmentCollection, self).__init__(**kwargs) - self.value = None - self.count = kwargs.get('count', None) - self.next_link = None - - -class IssueAttachmentContract(Resource): - """Issue Attachment Contract details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param title: Filename by which the binary data will be saved. - :type title: str - :param content_format: Either 'link' if content is provided via an HTTP link or the MIME type - of the Base64-encoded binary data provided in the 'content' property. - :type content_format: str - :param content: An HTTP link or Base64-encoded binary data. - :type content: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'content_format': {'key': 'properties.contentFormat', 'type': 'str'}, - 'content': {'key': 'properties.content', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IssueAttachmentContract, self).__init__(**kwargs) - self.title = kwargs.get('title', None) - self.content_format = kwargs.get('content_format', None) - self.content = kwargs.get('content', None) - - -class IssueCollection(msrest.serialization.Model): - """Paged Issue list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Issue values. - :vartype value: list[~azure.mgmt.apimanagement.models.IssueContract] - :param count: Total record count number across all pages. - :type count: long - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[IssueContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IssueCollection, self).__init__(**kwargs) - self.value = None - self.count = kwargs.get('count', None) - self.next_link = None - - -class IssueCommentCollection(msrest.serialization.Model): - """Paged Issue Comment list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Issue Comment values. - :vartype value: list[~azure.mgmt.apimanagement.models.IssueCommentContract] - :param count: Total record count number across all pages. - :type count: long - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[IssueCommentContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IssueCommentCollection, self).__init__(**kwargs) - self.value = None - self.count = kwargs.get('count', None) - self.next_link = None - - -class IssueCommentContract(Resource): - """Issue Comment Contract details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param text: Comment text. - :type text: str - :param created_date: Date and time when the comment was created. - :type created_date: ~datetime.datetime - :param user_id: A resource identifier for the user who left the comment. - :type user_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'text': {'key': 'properties.text', 'type': 'str'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'user_id': {'key': 'properties.userId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IssueCommentContract, self).__init__(**kwargs) - self.text = kwargs.get('text', None) - self.created_date = kwargs.get('created_date', None) - self.user_id = kwargs.get('user_id', None) - - -class IssueContract(Resource): - """Issue Contract details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param created_date: Date and time when the issue was created. - :type created_date: ~datetime.datetime - :param state: Status of the issue. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :type state: str or ~azure.mgmt.apimanagement.models.State - :param api_id: A resource identifier for the API the issue was created for. - :type api_id: str - :param title: The issue title. - :type title: str - :param description: Text describing the issue. - :type description: str - :param user_id: A resource identifier for the user created the issue. - :type user_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'api_id': {'key': 'properties.apiId', 'type': 'str'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'user_id': {'key': 'properties.userId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IssueContract, self).__init__(**kwargs) - self.created_date = kwargs.get('created_date', None) - self.state = kwargs.get('state', None) - self.api_id = kwargs.get('api_id', None) - self.title = kwargs.get('title', None) - self.description = kwargs.get('description', None) - self.user_id = kwargs.get('user_id', None) - - -class IssueContractBaseProperties(msrest.serialization.Model): - """Issue contract Base Properties. - - :param created_date: Date and time when the issue was created. - :type created_date: ~datetime.datetime - :param state: Status of the issue. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :type state: str or ~azure.mgmt.apimanagement.models.State - :param api_id: A resource identifier for the API the issue was created for. - :type api_id: str - """ - - _attribute_map = { - 'created_date': {'key': 'createdDate', 'type': 'iso-8601'}, - 'state': {'key': 'state', 'type': 'str'}, - 'api_id': {'key': 'apiId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IssueContractBaseProperties, self).__init__(**kwargs) - self.created_date = kwargs.get('created_date', None) - self.state = kwargs.get('state', None) - self.api_id = kwargs.get('api_id', None) - - -class IssueContractProperties(IssueContractBaseProperties): - """Issue contract Properties. - - All required parameters must be populated in order to send to Azure. - - :param created_date: Date and time when the issue was created. - :type created_date: ~datetime.datetime - :param state: Status of the issue. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :type state: str or ~azure.mgmt.apimanagement.models.State - :param api_id: A resource identifier for the API the issue was created for. - :type api_id: str - :param title: Required. The issue title. - :type title: str - :param description: Required. Text describing the issue. - :type description: str - :param user_id: Required. A resource identifier for the user created the issue. - :type user_id: str - """ - - _validation = { - 'title': {'required': True}, - 'description': {'required': True}, - 'user_id': {'required': True}, - } - - _attribute_map = { - 'created_date': {'key': 'createdDate', 'type': 'iso-8601'}, - 'state': {'key': 'state', 'type': 'str'}, - 'api_id': {'key': 'apiId', 'type': 'str'}, - 'title': {'key': 'title', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'user_id': {'key': 'userId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IssueContractProperties, self).__init__(**kwargs) - self.title = kwargs['title'] - self.description = kwargs['description'] - self.user_id = kwargs['user_id'] - - -class IssueUpdateContract(msrest.serialization.Model): - """Issue update Parameters. - - :param created_date: Date and time when the issue was created. - :type created_date: ~datetime.datetime - :param state: Status of the issue. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :type state: str or ~azure.mgmt.apimanagement.models.State - :param api_id: A resource identifier for the API the issue was created for. - :type api_id: str - :param title: The issue title. - :type title: str - :param description: Text describing the issue. - :type description: str - :param user_id: A resource identifier for the user created the issue. - :type user_id: str - """ - - _attribute_map = { - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'api_id': {'key': 'properties.apiId', 'type': 'str'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'user_id': {'key': 'properties.userId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IssueUpdateContract, self).__init__(**kwargs) - self.created_date = kwargs.get('created_date', None) - self.state = kwargs.get('state', None) - self.api_id = kwargs.get('api_id', None) - self.title = kwargs.get('title', None) - self.description = kwargs.get('description', None) - self.user_id = kwargs.get('user_id', None) - - -class IssueUpdateContractProperties(IssueContractBaseProperties): - """Issue contract Update Properties. - - :param created_date: Date and time when the issue was created. - :type created_date: ~datetime.datetime - :param state: Status of the issue. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :type state: str or ~azure.mgmt.apimanagement.models.State - :param api_id: A resource identifier for the API the issue was created for. - :type api_id: str - :param title: The issue title. - :type title: str - :param description: Text describing the issue. - :type description: str - :param user_id: A resource identifier for the user created the issue. - :type user_id: str - """ - - _attribute_map = { - 'created_date': {'key': 'createdDate', 'type': 'iso-8601'}, - 'state': {'key': 'state', 'type': 'str'}, - 'api_id': {'key': 'apiId', 'type': 'str'}, - 'title': {'key': 'title', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'user_id': {'key': 'userId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IssueUpdateContractProperties, self).__init__(**kwargs) - self.title = kwargs.get('title', None) - self.description = kwargs.get('description', None) - self.user_id = kwargs.get('user_id', None) - - -class KeyVaultContractCreateProperties(msrest.serialization.Model): - """Create keyVault contract details. - - :param 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. - :type secret_identifier: str - :param identity_client_id: SystemAssignedIdentity or UserAssignedIdentity Client Id which will - be used to access key vault secret. - :type identity_client_id: str - """ - - _attribute_map = { - 'secret_identifier': {'key': 'secretIdentifier', 'type': 'str'}, - 'identity_client_id': {'key': 'identityClientId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KeyVaultContractCreateProperties, self).__init__(**kwargs) - self.secret_identifier = kwargs.get('secret_identifier', None) - self.identity_client_id = kwargs.get('identity_client_id', None) - - -class KeyVaultContractProperties(KeyVaultContractCreateProperties): - """KeyVault contract details. - - :param 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. - :type secret_identifier: str - :param identity_client_id: SystemAssignedIdentity or UserAssignedIdentity Client Id which will - be used to access key vault secret. - :type identity_client_id: str - :param last_status: Last time sync and refresh status of secret from key vault. - :type last_status: ~azure.mgmt.apimanagement.models.KeyVaultLastAccessStatusContractProperties - """ - - _attribute_map = { - 'secret_identifier': {'key': 'secretIdentifier', 'type': 'str'}, - 'identity_client_id': {'key': 'identityClientId', 'type': 'str'}, - 'last_status': {'key': 'lastStatus', 'type': 'KeyVaultLastAccessStatusContractProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(KeyVaultContractProperties, self).__init__(**kwargs) - self.last_status = kwargs.get('last_status', None) - - -class KeyVaultLastAccessStatusContractProperties(msrest.serialization.Model): - """Issue contract Update Properties. - - :param code: Last status code for sync and refresh of secret from key vault. - :type code: str - :param message: Details of the error else empty. - :type message: str - :param time_stamp_utc: Last time secret was accessed. The date conforms to the following - format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type time_stamp_utc: ~datetime.datetime - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'time_stamp_utc': {'key': 'timeStampUtc', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(KeyVaultLastAccessStatusContractProperties, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.time_stamp_utc = kwargs.get('time_stamp_utc', None) - - -class LoggerCollection(msrest.serialization.Model): - """Paged Logger list representation. - - :param value: Logger values. - :type value: list[~azure.mgmt.apimanagement.models.LoggerContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[LoggerContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LoggerCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class LoggerContract(Resource): - """Logger details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param logger_type: Logger type. Possible values include: "azureEventHub", - "applicationInsights", "azureMonitor". - :type logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType - :param description: Logger description. - :type description: str - :param credentials: The name and SendRule connection string of the event hub for azureEventHub - logger. - Instrumentation key for applicationInsights logger. - :type credentials: dict[str, str] - :param is_buffered: Whether records are buffered in the logger before publishing. Default is - assumed to be true. - :type is_buffered: bool - :param resource_id: Azure Resource Id of a log target (either Azure Event Hub resource or Azure - Application Insights resource). - :type resource_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'description': {'max_length': 256, 'min_length': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'logger_type': {'key': 'properties.loggerType', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'credentials': {'key': 'properties.credentials', 'type': '{str}'}, - 'is_buffered': {'key': 'properties.isBuffered', 'type': 'bool'}, - 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LoggerContract, self).__init__(**kwargs) - self.logger_type = kwargs.get('logger_type', None) - self.description = kwargs.get('description', None) - self.credentials = kwargs.get('credentials', None) - self.is_buffered = kwargs.get('is_buffered', None) - self.resource_id = kwargs.get('resource_id', None) - - -class LoggerUpdateContract(msrest.serialization.Model): - """Logger update contract. - - :param logger_type: Logger type. Possible values include: "azureEventHub", - "applicationInsights", "azureMonitor". - :type logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType - :param description: Logger description. - :type description: str - :param credentials: Logger credentials. - :type credentials: dict[str, str] - :param is_buffered: Whether records are buffered in the logger before publishing. Default is - assumed to be true. - :type is_buffered: bool - """ - - _attribute_map = { - 'logger_type': {'key': 'properties.loggerType', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'credentials': {'key': 'properties.credentials', 'type': '{str}'}, - 'is_buffered': {'key': 'properties.isBuffered', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(LoggerUpdateContract, self).__init__(**kwargs) - self.logger_type = kwargs.get('logger_type', None) - self.description = kwargs.get('description', None) - self.credentials = kwargs.get('credentials', None) - self.is_buffered = kwargs.get('is_buffered', None) - - -class NamedValueCollection(msrest.serialization.Model): - """Paged NamedValue list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.NamedValueContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[NamedValueContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NamedValueCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class NamedValueContract(Resource): - """NamedValue details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. - :type tags: list[str] - :param secret: Determines whether the value is a secret and should be encrypted or not. Default - value is false. - :type secret: bool - :param display_name: Unique name of NamedValue. It may contain only letters, digits, period, - dash, and underscore characters. - :type display_name: str - :param 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. - :type value: str - :param key_vault: KeyVault location details of the namedValue. - :type 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}, - } - - _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'}, - } - - def __init__( - self, - **kwargs - ): - super(NamedValueContract, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.secret = kwargs.get('secret', None) - self.display_name = kwargs.get('display_name', None) - self.value = kwargs.get('value', None) - self.key_vault = kwargs.get('key_vault', None) - - -class NamedValueEntityBaseParameters(msrest.serialization.Model): - """NamedValue Entity Base Parameters set. - - :param tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. - :type tags: list[str] - :param secret: Determines whether the value is a secret and should be encrypted or not. Default - value is false. - :type secret: bool - """ - - _validation = { - 'tags': {'max_items': 32, 'min_items': 0}, - } - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '[str]'}, - 'secret': {'key': 'secret', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(NamedValueEntityBaseParameters, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.secret = kwargs.get('secret', None) - - -class NamedValueContractProperties(NamedValueEntityBaseParameters): - """NamedValue Contract properties. - - All required parameters must be populated in order to send to Azure. - - :param tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. - :type tags: list[str] - :param secret: Determines whether the value is a secret and should be encrypted or not. Default - value is false. - :type secret: bool - :param display_name: Required. Unique name of NamedValue. It may contain only letters, digits, - period, dash, and underscore characters. - :type display_name: str - :param 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. - :type value: str - :param key_vault: KeyVault location details of the namedValue. - :type 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}, - } - - _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'}, - } - - def __init__( - self, - **kwargs - ): - super(NamedValueContractProperties, self).__init__(**kwargs) - self.display_name = kwargs['display_name'] - self.value = kwargs.get('value', None) - self.key_vault = kwargs.get('key_vault', None) - - -class NamedValueCreateContract(Resource): - """NamedValue details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. - :type tags: list[str] - :param secret: Determines whether the value is a secret and should be encrypted or not. Default - value is false. - :type secret: bool - :param display_name: Unique name of NamedValue. It may contain only letters, digits, period, - dash, and underscore characters. - :type display_name: str - :param 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. - :type value: str - :param key_vault: KeyVault location details of the namedValue. - :type 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}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'properties.tags', 'type': '[str]'}, - 'secret': {'key': 'properties.secret', 'type': 'bool'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'value': {'key': 'properties.value', 'type': 'str'}, - 'key_vault': {'key': 'properties.keyVault', 'type': 'KeyVaultContractCreateProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(NamedValueCreateContract, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.secret = kwargs.get('secret', None) - self.display_name = kwargs.get('display_name', None) - self.value = kwargs.get('value', None) - self.key_vault = kwargs.get('key_vault', None) - - -class NamedValueCreateContractProperties(NamedValueEntityBaseParameters): - """NamedValue Contract properties. - - All required parameters must be populated in order to send to Azure. - - :param tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. - :type tags: list[str] - :param secret: Determines whether the value is a secret and should be encrypted or not. Default - value is false. - :type secret: bool - :param display_name: Required. Unique name of NamedValue. It may contain only letters, digits, - period, dash, and underscore characters. - :type display_name: str - :param 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. - :type value: str - :param key_vault: KeyVault location details of the namedValue. - :type 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}, - } - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '[str]'}, - 'secret': {'key': 'secret', 'type': 'bool'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'key_vault': {'key': 'keyVault', 'type': 'KeyVaultContractCreateProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(NamedValueCreateContractProperties, self).__init__(**kwargs) - self.display_name = kwargs['display_name'] - self.value = kwargs.get('value', None) - self.key_vault = kwargs.get('key_vault', None) - - -class NamedValueSecretContract(msrest.serialization.Model): - """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. - - :param value: This is secret value of the NamedValue entity. - :type value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NamedValueSecretContract, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class NamedValueUpdateParameterProperties(NamedValueEntityBaseParameters): - """NamedValue Contract properties. - - :param tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. - :type tags: list[str] - :param secret: Determines whether the value is a secret and should be encrypted or not. Default - value is false. - :type secret: bool - :param display_name: Unique name of NamedValue. It may contain only letters, digits, period, - dash, and underscore characters. - :type display_name: str - :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or - consist only of whitespace. - :type value: str - :param key_vault: KeyVault location details of the namedValue. - :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties - """ - - _validation = { - 'tags': {'max_items': 32, 'min_items': 0}, - 'display_name': {'max_length': 256, 'min_length': 1, 'pattern': r'^[A-Za-z0-9-._]+$'}, - 'value': {'max_length': 4096, 'min_length': 1}, - } - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '[str]'}, - 'secret': {'key': 'secret', 'type': 'bool'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'key_vault': {'key': 'keyVault', 'type': 'KeyVaultContractCreateProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(NamedValueUpdateParameterProperties, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.value = kwargs.get('value', None) - self.key_vault = kwargs.get('key_vault', None) - - -class NamedValueUpdateParameters(msrest.serialization.Model): - """NamedValue update Parameters. - - :param tags: A set of tags. Optional tags that when provided can be used to filter the - NamedValue list. - :type tags: list[str] - :param secret: Determines whether the value is a secret and should be encrypted or not. Default - value is false. - :type secret: bool - :param display_name: Unique name of NamedValue. It may contain only letters, digits, period, - dash, and underscore characters. - :type display_name: str - :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or - consist only of whitespace. - :type value: str - :param key_vault: KeyVault location details of the namedValue. - :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties - """ - - _validation = { - 'tags': {'max_items': 32, 'min_items': 0}, - 'display_name': {'max_length': 256, 'min_length': 1, 'pattern': r'^[A-Za-z0-9-._]+$'}, - 'value': {'max_length': 4096, 'min_length': 1}, - } - - _attribute_map = { - 'tags': {'key': 'properties.tags', 'type': '[str]'}, - 'secret': {'key': 'properties.secret', 'type': 'bool'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'value': {'key': 'properties.value', 'type': 'str'}, - 'key_vault': {'key': 'properties.keyVault', 'type': 'KeyVaultContractCreateProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(NamedValueUpdateParameters, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.secret = kwargs.get('secret', None) - self.display_name = kwargs.get('display_name', None) - self.value = kwargs.get('value', None) - self.key_vault = kwargs.get('key_vault', None) - - -class NetworkStatusContract(msrest.serialization.Model): - """Network Status details. - - All required parameters must be populated in order to send to Azure. - - :param dns_servers: Required. Gets the list of DNS servers IPV4 addresses. - :type dns_servers: list[str] - :param connectivity_status: Required. Gets the list of Connectivity Status to the Resources on - which the service depends upon. - :type connectivity_status: list[~azure.mgmt.apimanagement.models.ConnectivityStatusContract] - """ - - _validation = { - 'dns_servers': {'required': True}, - 'connectivity_status': {'required': True}, - } - - _attribute_map = { - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, - 'connectivity_status': {'key': 'connectivityStatus', 'type': '[ConnectivityStatusContract]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkStatusContract, self).__init__(**kwargs) - self.dns_servers = kwargs['dns_servers'] - self.connectivity_status = kwargs['connectivity_status'] - - -class NetworkStatusContractByLocation(msrest.serialization.Model): - """Network Status in the Location. - - :param location: Location of service. - :type location: str - :param network_status: Network status in Location. - :type network_status: ~azure.mgmt.apimanagement.models.NetworkStatusContract - """ - - _validation = { - 'location': {'min_length': 1}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'network_status': {'key': 'networkStatus', 'type': 'NetworkStatusContract'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkStatusContractByLocation, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.network_status = kwargs.get('network_status', None) - - -class NotificationCollection(msrest.serialization.Model): - """Paged Notification list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.NotificationContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[NotificationContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NotificationCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class NotificationContract(Resource): - """Notification details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param title: Title of the Notification. - :type title: str - :param description: Description of the Notification. - :type description: str - :param recipients: Recipient Parameter values. - :type recipients: ~azure.mgmt.apimanagement.models.RecipientsContractProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'title': {'max_length': 1000, 'min_length': 1}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'recipients': {'key': 'properties.recipients', 'type': 'RecipientsContractProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(NotificationContract, self).__init__(**kwargs) - self.title = kwargs.get('title', None) - self.description = kwargs.get('description', None) - self.recipients = kwargs.get('recipients', None) - - -class OAuth2AuthenticationSettingsContract(msrest.serialization.Model): - """API OAuth2 Authentication settings details. - - :param authorization_server_id: OAuth authorization server identifier. - :type authorization_server_id: str - :param scope: operations scope. - :type scope: str - """ - - _attribute_map = { - 'authorization_server_id': {'key': 'authorizationServerId', 'type': 'str'}, - 'scope': {'key': 'scope', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OAuth2AuthenticationSettingsContract, self).__init__(**kwargs) - self.authorization_server_id = kwargs.get('authorization_server_id', None) - self.scope = kwargs.get('scope', None) - - -class OpenIdAuthenticationSettingsContract(msrest.serialization.Model): - """API OAuth2 Authentication settings details. - - :param openid_provider_id: OAuth authorization server identifier. - :type openid_provider_id: str - :param bearer_token_sending_methods: How to send token to the server. - :type bearer_token_sending_methods: list[str or - ~azure.mgmt.apimanagement.models.BearerTokenSendingMethods] - """ - - _attribute_map = { - 'openid_provider_id': {'key': 'openidProviderId', 'type': 'str'}, - 'bearer_token_sending_methods': {'key': 'bearerTokenSendingMethods', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(OpenIdAuthenticationSettingsContract, self).__init__(**kwargs) - self.openid_provider_id = kwargs.get('openid_provider_id', None) - self.bearer_token_sending_methods = kwargs.get('bearer_token_sending_methods', None) - - -class OpenIdConnectProviderCollection(msrest.serialization.Model): - """Paged OpenIdProviders list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[OpenidConnectProviderContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OpenIdConnectProviderCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class OpenidConnectProviderContract(Resource): - """OpenId Connect Provider details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param display_name: User-friendly OpenID Connect Provider name. - :type display_name: str - :param description: User-friendly description of OpenID Connect Provider. - :type description: str - :param metadata_endpoint: Metadata endpoint URI. - :type metadata_endpoint: str - :param client_id: Client ID of developer console which is the client application. - :type client_id: str - :param client_secret: Client Secret of developer console which is the client application. - :type client_secret: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'max_length': 50, 'min_length': 0}, - } - - _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'}, - } - - def __init__( - self, - **kwargs - ): - super(OpenidConnectProviderContract, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.description = kwargs.get('description', None) - self.metadata_endpoint = kwargs.get('metadata_endpoint', None) - self.client_id = kwargs.get('client_id', None) - self.client_secret = kwargs.get('client_secret', None) - - -class OpenidConnectProviderUpdateContract(msrest.serialization.Model): - """Parameters supplied to the Update OpenID Connect Provider operation. - - :param display_name: User-friendly OpenID Connect Provider name. - :type display_name: str - :param description: User-friendly description of OpenID Connect Provider. - :type description: str - :param metadata_endpoint: Metadata endpoint URI. - :type metadata_endpoint: str - :param client_id: Client ID of developer console which is the client application. - :type client_id: str - :param client_secret: Client Secret of developer console which is the client application. - :type client_secret: str - """ - - _validation = { - 'display_name': {'max_length': 50, 'min_length': 0}, - } - - _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'}, - } - - def __init__( - self, - **kwargs - ): - super(OpenidConnectProviderUpdateContract, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.description = kwargs.get('description', None) - self.metadata_endpoint = kwargs.get('metadata_endpoint', None) - self.client_id = kwargs.get('client_id', None) - self.client_secret = kwargs.get('client_secret', None) - - -class Operation(msrest.serialization.Model): - """REST API operation. - - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that describes the operation. - :type display: ~azure.mgmt.apimanagement.models.OperationDisplay - :param origin: The operation origin. - :type origin: str - :param properties: The operation properties. - :type properties: any - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - self.properties = kwargs.get('properties', None) - - -class OperationCollection(msrest.serialization.Model): - """Paged Operation list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.OperationContract] - :param count: Total record count number across all pages. - :type count: long - :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'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationCollection, self).__init__(**kwargs) - self.value = None - self.count = kwargs.get('count', None) - self.next_link = None - - -class OperationContract(Resource): - """Api Operation details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param template_parameters: Collection of URL template parameters. - :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :param description: Description of the operation. May include HTML formatting tags. - :type description: str - :param request: An entity containing request details. - :type request: ~azure.mgmt.apimanagement.models.RequestContract - :param responses: Array of Operation responses. - :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :param policies: Operation Policies. - :type policies: str - :param display_name: Operation Name. - :type display_name: str - :param method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not - limited by only them. - :type method: str - :param url_template: Relative URL template identifying the target resource for this operation. - May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. - :type url_template: 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}, - 'url_template': {'max_length': 1000, 'min_length': 1}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'template_parameters': {'key': 'properties.templateParameters', 'type': '[ParameterContract]'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'request': {'key': 'properties.request', 'type': 'RequestContract'}, - 'responses': {'key': 'properties.responses', 'type': '[ResponseContract]'}, - 'policies': {'key': 'properties.policies', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'method': {'key': 'properties.method', 'type': 'str'}, - 'url_template': {'key': 'properties.urlTemplate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationContract, self).__init__(**kwargs) - self.template_parameters = kwargs.get('template_parameters', None) - self.description = kwargs.get('description', None) - self.request = kwargs.get('request', None) - self.responses = kwargs.get('responses', None) - self.policies = kwargs.get('policies', None) - self.display_name = kwargs.get('display_name', None) - self.method = kwargs.get('method', None) - self.url_template = kwargs.get('url_template', None) - - -class OperationEntityBaseContract(msrest.serialization.Model): - """Api Operation Entity Base Contract details. - - :param template_parameters: Collection of URL template parameters. - :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :param description: Description of the operation. May include HTML formatting tags. - :type description: str - :param request: An entity containing request details. - :type request: ~azure.mgmt.apimanagement.models.RequestContract - :param responses: Array of Operation responses. - :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :param policies: Operation Policies. - :type policies: str - """ - - _validation = { - 'description': {'max_length': 1000, 'min_length': 0}, - } - - _attribute_map = { - 'template_parameters': {'key': 'templateParameters', 'type': '[ParameterContract]'}, - 'description': {'key': 'description', 'type': 'str'}, - 'request': {'key': 'request', 'type': 'RequestContract'}, - 'responses': {'key': 'responses', 'type': '[ResponseContract]'}, - 'policies': {'key': 'policies', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationEntityBaseContract, self).__init__(**kwargs) - self.template_parameters = kwargs.get('template_parameters', None) - self.description = kwargs.get('description', None) - self.request = kwargs.get('request', None) - self.responses = kwargs.get('responses', None) - self.policies = kwargs.get('policies', None) - - -class OperationContractProperties(OperationEntityBaseContract): - """Operation Contract Properties. - - All required parameters must be populated in order to send to Azure. - - :param template_parameters: Collection of URL template parameters. - :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :param description: Description of the operation. May include HTML formatting tags. - :type description: str - :param request: An entity containing request details. - :type request: ~azure.mgmt.apimanagement.models.RequestContract - :param responses: Array of Operation responses. - :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :param policies: Operation Policies. - :type policies: str - :param display_name: Required. Operation Name. - :type display_name: str - :param method: Required. A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, - POST but not limited by only them. - :type method: str - :param url_template: Required. Relative URL template identifying the target resource for this - operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. - :type 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}, - } - - _attribute_map = { - 'template_parameters': {'key': 'templateParameters', 'type': '[ParameterContract]'}, - 'description': {'key': 'description', 'type': 'str'}, - 'request': {'key': 'request', 'type': 'RequestContract'}, - 'responses': {'key': 'responses', 'type': '[ResponseContract]'}, - 'policies': {'key': 'policies', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'method': {'key': 'method', 'type': 'str'}, - 'url_template': {'key': 'urlTemplate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationContractProperties, self).__init__(**kwargs) - self.display_name = kwargs['display_name'] - self.method = kwargs['method'] - self.url_template = kwargs['url_template'] - - -class OperationDisplay(msrest.serialization.Model): - """The object that describes the operation. - - :param provider: Friendly name of the resource provider. - :type provider: str - :param operation: Operation type: read, write, delete, listKeys/action, etc. - :type operation: str - :param resource: Resource type on which the operation is performed. - :type resource: str - :param description: Friendly name of the operation. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.operation = kwargs.get('operation', None) - self.resource = kwargs.get('resource', None) - self.description = kwargs.get('description', None) - - -class OperationListResult(msrest.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. - - :param value: List of operations supported by the resource provider. - :type value: list[~azure.mgmt.apimanagement.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class OperationResultContract(Resource): - """Long Running Git Operation Results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param id_properties_id: Operation result identifier. - :type id_properties_id: str - :param status: Status of an async operation. Possible values include: "Started", "InProgress", - "Succeeded", "Failed". - :type status: str or ~azure.mgmt.apimanagement.models.AsyncOperationStatus - :param 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. - :type started: ~datetime.datetime - :param updated: Last update time of an async operation. The date conforms to the following - format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type updated: ~datetime.datetime - :param result_info: Optional result info. - :type result_info: str - :param error: Error Body Contract. - :type error: ~azure.mgmt.apimanagement.models.ErrorResponseBody - :ivar action_log: This property if only provided as part of the TenantConfiguration_Validate - operation. It contains the log the entities which will be updated/created/deleted as part of - the TenantConfiguration_Deploy operation. - :vartype action_log: list[~azure.mgmt.apimanagement.models.OperationResultLogItemContract] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'action_log': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'id_properties_id': {'key': 'properties.id', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'started': {'key': 'properties.started', 'type': 'iso-8601'}, - 'updated': {'key': 'properties.updated', 'type': 'iso-8601'}, - 'result_info': {'key': 'properties.resultInfo', 'type': 'str'}, - 'error': {'key': 'properties.error', 'type': 'ErrorResponseBody'}, - 'action_log': {'key': 'properties.actionLog', 'type': '[OperationResultLogItemContract]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationResultContract, self).__init__(**kwargs) - self.id_properties_id = kwargs.get('id_properties_id', None) - self.status = kwargs.get('status', None) - self.started = kwargs.get('started', None) - self.updated = kwargs.get('updated', None) - self.result_info = kwargs.get('result_info', None) - self.error = kwargs.get('error', None) - self.action_log = None - - -class OperationResultLogItemContract(msrest.serialization.Model): - """Log of the entity being created, updated or deleted. - - :param object_type: The type of entity contract. - :type object_type: str - :param action: Action like create/update/delete. - :type action: str - :param object_key: Identifier of the entity being created/updated/deleted. - :type object_key: str - """ - - _attribute_map = { - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'object_key': {'key': 'objectKey', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationResultLogItemContract, self).__init__(**kwargs) - self.object_type = kwargs.get('object_type', None) - self.action = kwargs.get('action', None) - self.object_key = kwargs.get('object_key', None) - - -class OperationTagResourceContractProperties(msrest.serialization.Model): - """Operation Entity contract Properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param id: Identifier of the operation in form /operations/{operationId}. - :type id: str - :ivar name: Operation name. - :vartype name: str - :ivar api_name: Api Name. - :vartype api_name: str - :ivar api_revision: Api Revision. - :vartype api_revision: str - :ivar api_version: Api Version. - :vartype api_version: str - :ivar description: Operation Description. - :vartype description: str - :ivar method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not - limited by only them. - :vartype method: str - :ivar url_template: Relative URL template identifying the target resource for this operation. - May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. - :vartype url_template: str - """ - - _validation = { - 'name': {'readonly': True}, - 'api_name': {'readonly': True}, - 'api_revision': {'readonly': True}, - 'api_version': {'readonly': True}, - 'description': {'readonly': True}, - 'method': {'readonly': True}, - 'url_template': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'api_name': {'key': 'apiName', 'type': 'str'}, - 'api_revision': {'key': 'apiRevision', 'type': 'str'}, - 'api_version': {'key': 'apiVersion', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'method': {'key': 'method', 'type': 'str'}, - 'url_template': {'key': 'urlTemplate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationTagResourceContractProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = None - self.api_name = None - self.api_revision = None - self.api_version = None - self.description = None - self.method = None - self.url_template = None - - -class OperationUpdateContract(msrest.serialization.Model): - """Api Operation Update Contract details. - - :param template_parameters: Collection of URL template parameters. - :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :param description: Description of the operation. May include HTML formatting tags. - :type description: str - :param request: An entity containing request details. - :type request: ~azure.mgmt.apimanagement.models.RequestContract - :param responses: Array of Operation responses. - :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :param policies: Operation Policies. - :type policies: str - :param display_name: Operation Name. - :type display_name: str - :param method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not - limited by only them. - :type method: str - :param url_template: Relative URL template identifying the target resource for this operation. - May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. - :type url_template: str - """ - - _validation = { - 'description': {'max_length': 1000, 'min_length': 0}, - 'display_name': {'max_length': 300, 'min_length': 1}, - 'url_template': {'max_length': 1000, 'min_length': 1}, - } - - _attribute_map = { - 'template_parameters': {'key': 'properties.templateParameters', 'type': '[ParameterContract]'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'request': {'key': 'properties.request', 'type': 'RequestContract'}, - 'responses': {'key': 'properties.responses', 'type': '[ResponseContract]'}, - 'policies': {'key': 'properties.policies', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'method': {'key': 'properties.method', 'type': 'str'}, - 'url_template': {'key': 'properties.urlTemplate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationUpdateContract, self).__init__(**kwargs) - self.template_parameters = kwargs.get('template_parameters', None) - self.description = kwargs.get('description', None) - self.request = kwargs.get('request', None) - self.responses = kwargs.get('responses', None) - self.policies = kwargs.get('policies', None) - self.display_name = kwargs.get('display_name', None) - self.method = kwargs.get('method', None) - self.url_template = kwargs.get('url_template', None) - - -class OperationUpdateContractProperties(OperationEntityBaseContract): - """Operation Update Contract Properties. - - :param template_parameters: Collection of URL template parameters. - :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :param description: Description of the operation. May include HTML formatting tags. - :type description: str - :param request: An entity containing request details. - :type request: ~azure.mgmt.apimanagement.models.RequestContract - :param responses: Array of Operation responses. - :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :param policies: Operation Policies. - :type policies: str - :param display_name: Operation Name. - :type display_name: str - :param method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not - limited by only them. - :type method: str - :param url_template: Relative URL template identifying the target resource for this operation. - May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. - :type url_template: str - """ - - _validation = { - 'description': {'max_length': 1000, 'min_length': 0}, - 'display_name': {'max_length': 300, 'min_length': 1}, - 'url_template': {'max_length': 1000, 'min_length': 1}, - } - - _attribute_map = { - 'template_parameters': {'key': 'templateParameters', 'type': '[ParameterContract]'}, - 'description': {'key': 'description', 'type': 'str'}, - 'request': {'key': 'request', 'type': 'RequestContract'}, - 'responses': {'key': 'responses', 'type': '[ResponseContract]'}, - 'policies': {'key': 'policies', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'method': {'key': 'method', 'type': 'str'}, - 'url_template': {'key': 'urlTemplate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationUpdateContractProperties, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.method = kwargs.get('method', None) - self.url_template = kwargs.get('url_template', None) - - -class ParameterContract(msrest.serialization.Model): - """Operation parameters details. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Parameter name. - :type name: str - :param description: Parameter description. - :type description: str - :param type: Required. Parameter type. - :type type: str - :param default_value: Default parameter value. - :type default_value: str - :param required: Specifies whether parameter is required or not. - :type required: bool - :param values: Parameter values. - :type values: list[str] - """ - - _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'default_value': {'key': 'defaultValue', 'type': 'str'}, - 'required': {'key': 'required', 'type': 'bool'}, - 'values': {'key': 'values', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ParameterContract, self).__init__(**kwargs) - self.name = kwargs['name'] - self.description = kwargs.get('description', None) - self.type = kwargs['type'] - self.default_value = kwargs.get('default_value', None) - self.required = kwargs.get('required', None) - self.values = kwargs.get('values', None) - - -class PipelineDiagnosticSettings(msrest.serialization.Model): - """Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. - - :param request: Diagnostic settings for request. - :type request: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic - :param response: Diagnostic settings for response. - :type response: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic - """ - - _attribute_map = { - 'request': {'key': 'request', 'type': 'HttpMessageDiagnostic'}, - 'response': {'key': 'response', 'type': 'HttpMessageDiagnostic'}, - } - - def __init__( - self, - **kwargs - ): - super(PipelineDiagnosticSettings, self).__init__(**kwargs) - self.request = kwargs.get('request', None) - self.response = kwargs.get('response', None) - - -class PolicyCollection(msrest.serialization.Model): - """The response of the list policy operation. - - :param value: Policy Contract value. - :type value: list[~azure.mgmt.apimanagement.models.PolicyContract] - :param count: Total record count number. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PolicyCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class PolicyContract(Resource): - """Policy Contract details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param value: Contents of the Policy as defined by the format. - :type value: str - :param format: Format of the policyContent. Possible values include: "xml", "xml-link", - "rawxml", "rawxml-link". Default value: "xml". - :type format: str or ~azure.mgmt.apimanagement.models.PolicyContentFormat - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'properties.value', 'type': 'str'}, - 'format': {'key': 'properties.format', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PolicyContract, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.format = kwargs.get('format', "xml") - - -class PolicyDescriptionCollection(msrest.serialization.Model): - """Descriptions of APIM policies. - - :param value: Descriptions of APIM policies. - :type value: list[~azure.mgmt.apimanagement.models.PolicyDescriptionContract] - :param count: Total record count number. - :type count: long - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyDescriptionContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(PolicyDescriptionCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - - -class PolicyDescriptionContract(Resource): - """Policy description details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :ivar description: Policy description. - :vartype description: str - :ivar scope: Binary OR value of the Snippet scope. - :vartype scope: long - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'description': {'readonly': True}, - 'scope': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(PolicyDescriptionContract, self).__init__(**kwargs) - self.description = None - self.scope = None - - -class PortalDelegationSettings(Resource): - """Delegation settings for a developer portal. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param url: A delegation Url. - :type url: str - :param validation_key: A base64-encoded validation key to validate, that a request is coming - from Azure API Management. - :type validation_key: str - :param subscriptions: Subscriptions delegation settings. - :type subscriptions: ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties - :param user_registration: User registration delegation settings. - :type user_registration: - ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'url': {'key': 'properties.url', 'type': 'str'}, - 'validation_key': {'key': 'properties.validationKey', 'type': 'str'}, - 'subscriptions': {'key': 'properties.subscriptions', 'type': 'SubscriptionsDelegationSettingsProperties'}, - 'user_registration': {'key': 'properties.userRegistration', 'type': 'RegistrationDelegationSettingsProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(PortalDelegationSettings, self).__init__(**kwargs) - self.url = kwargs.get('url', None) - self.validation_key = kwargs.get('validation_key', None) - self.subscriptions = kwargs.get('subscriptions', None) - self.user_registration = kwargs.get('user_registration', None) - - -class PortalRevisionCollection(msrest.serialization.Model): - """Paged list of portal revisions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Collection of portal revisions. - :vartype value: list[~azure.mgmt.apimanagement.models.PortalRevisionContract] - :ivar next_link: Next page link, if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PortalRevisionContract]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PortalRevisionCollection, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class PortalRevisionContract(Resource): - """Portal revisions contract details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param description: Portal revision description. - :type description: str - :ivar status_details: Portal revision publishing status details. - :vartype status_details: str - :ivar status: Portal revision publishing status. Possible values include: "pending", - "publishing", "completed", "failed". - :vartype status: str or ~azure.mgmt.apimanagement.models.PortalRevisionStatus - :param is_current: Indicates if the Portal Revision is public. - :type is_current: bool - :ivar created_date_time: Portal revision creation date and time. - :vartype created_date_time: ~datetime.datetime - :ivar updated_date_time: Last updated date and time. - :vartype updated_date_time: ~datetime.datetime - """ - - _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}, - } - - _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'}, - } - - def __init__( - self, - **kwargs - ): - super(PortalRevisionContract, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.status_details = None - self.status = None - self.is_current = kwargs.get('is_current', None) - self.created_date_time = None - self.updated_date_time = None - - -class PortalSettingsCollection(msrest.serialization.Model): - """Descriptions of APIM policies. - - :param value: Descriptions of APIM policies. - :type value: list[~azure.mgmt.apimanagement.models.PortalSettingsContract] - :param count: Total record count number. - :type count: long - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PortalSettingsContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(PortalSettingsCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - - -class PortalSettingsContract(Resource): - """Portal Settings for the Developer Portal. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param url: A delegation Url. - :type url: str - :param validation_key: A base64-encoded validation key to validate, that a request is coming - from Azure API Management. - :type validation_key: str - :param subscriptions: Subscriptions delegation settings. - :type subscriptions: ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties - :param user_registration: User registration delegation settings. - :type user_registration: - ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties - :param enabled: Redirect Anonymous users to the Sign-In page. - :type enabled: bool - :param terms_of_service: Terms of service contract properties. - :type terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'url': {'key': 'properties.url', 'type': 'str'}, - 'validation_key': {'key': 'properties.validationKey', 'type': 'str'}, - 'subscriptions': {'key': 'properties.subscriptions', 'type': 'SubscriptionsDelegationSettingsProperties'}, - 'user_registration': {'key': 'properties.userRegistration', 'type': 'RegistrationDelegationSettingsProperties'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'terms_of_service': {'key': 'properties.termsOfService', 'type': 'TermsOfServiceProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(PortalSettingsContract, self).__init__(**kwargs) - self.url = kwargs.get('url', None) - self.validation_key = kwargs.get('validation_key', None) - self.subscriptions = kwargs.get('subscriptions', None) - self.user_registration = kwargs.get('user_registration', None) - self.enabled = kwargs.get('enabled', None) - self.terms_of_service = kwargs.get('terms_of_service', None) - - -class PortalSettingValidationKeyContract(msrest.serialization.Model): - """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. - - :param validation_key: This is secret value of the validation key in portal settings. - :type validation_key: str - """ - - _attribute_map = { - 'validation_key': {'key': 'validationKey', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PortalSettingValidationKeyContract, self).__init__(**kwargs) - self.validation_key = kwargs.get('validation_key', None) - - -class PortalSigninSettings(Resource): - """Sign-In settings for the Developer Portal. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param enabled: Redirect Anonymous users to the Sign-In page. - :type enabled: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(PortalSigninSettings, self).__init__(**kwargs) - self.enabled = kwargs.get('enabled', None) - - -class PortalSignupSettings(Resource): - """Sign-Up settings for a developer portal. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param enabled: Allow users to sign up on a developer portal. - :type enabled: bool - :param terms_of_service: Terms of service contract properties. - :type terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'terms_of_service': {'key': 'properties.termsOfService', 'type': 'TermsOfServiceProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(PortalSignupSettings, self).__init__(**kwargs) - self.enabled = kwargs.get('enabled', None) - self.terms_of_service = kwargs.get('terms_of_service', None) - - -class ProductCollection(msrest.serialization.Model): - """Paged Products list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.ProductContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ProductContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProductCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class ProductContract(Resource): - """Product details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param description: Product description. May include HTML formatting tags. - :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the product will be - presented and required to accept these terms before they can complete the subscription process. - :type terms: str - :param subscription_required: Whether a product subscription is required for accessing APIs - included in this product. If true, the product is referred to as "protected" and a valid - subscription key is required for a request to an API included in the product to succeed. If - false, the product is referred to as "open" and requests to an API included in the product can - be made without a subscription key. If property is omitted when creating a new product it's - value is assumed to be true. - :type subscription_required: bool - :param approval_required: whether subscription approval is required. If false, new - subscriptions will be approved automatically enabling developers to call the product’s APIs - immediately after subscribing. If true, administrators must manually approve the subscription - before the developer can any of the product’s APIs. Can be present only if subscriptionRequired - property is present and has a value of false. - :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can have to this product - at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present - only if subscriptionRequired property is present and has a value of false. - :type subscriptions_limit: int - :param 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". - :type state: str or ~azure.mgmt.apimanagement.models.ProductState - :param display_name: Product name. - :type 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}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'terms': {'key': 'properties.terms', 'type': 'str'}, - 'subscription_required': {'key': 'properties.subscriptionRequired', 'type': 'bool'}, - 'approval_required': {'key': 'properties.approvalRequired', 'type': 'bool'}, - 'subscriptions_limit': {'key': 'properties.subscriptionsLimit', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProductContract, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.terms = kwargs.get('terms', None) - self.subscription_required = kwargs.get('subscription_required', None) - self.approval_required = kwargs.get('approval_required', None) - self.subscriptions_limit = kwargs.get('subscriptions_limit', None) - self.state = kwargs.get('state', None) - self.display_name = kwargs.get('display_name', None) - - -class ProductEntityBaseParameters(msrest.serialization.Model): - """Product Entity Base Parameters. - - :param description: Product description. May include HTML formatting tags. - :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the product will be - presented and required to accept these terms before they can complete the subscription process. - :type terms: str - :param subscription_required: Whether a product subscription is required for accessing APIs - included in this product. If true, the product is referred to as "protected" and a valid - subscription key is required for a request to an API included in the product to succeed. If - false, the product is referred to as "open" and requests to an API included in the product can - be made without a subscription key. If property is omitted when creating a new product it's - value is assumed to be true. - :type subscription_required: bool - :param approval_required: whether subscription approval is required. If false, new - subscriptions will be approved automatically enabling developers to call the product’s APIs - immediately after subscribing. If true, administrators must manually approve the subscription - before the developer can any of the product’s APIs. Can be present only if subscriptionRequired - property is present and has a value of false. - :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can have to this product - at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present - only if subscriptionRequired property is present and has a value of false. - :type subscriptions_limit: int - :param 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". - :type state: str or ~azure.mgmt.apimanagement.models.ProductState - """ - - _validation = { - 'description': {'max_length': 1000, 'min_length': 0}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'terms': {'key': 'terms', 'type': 'str'}, - 'subscription_required': {'key': 'subscriptionRequired', 'type': 'bool'}, - 'approval_required': {'key': 'approvalRequired', 'type': 'bool'}, - 'subscriptions_limit': {'key': 'subscriptionsLimit', 'type': 'int'}, - 'state': {'key': 'state', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProductEntityBaseParameters, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.terms = kwargs.get('terms', None) - self.subscription_required = kwargs.get('subscription_required', None) - self.approval_required = kwargs.get('approval_required', None) - self.subscriptions_limit = kwargs.get('subscriptions_limit', None) - self.state = kwargs.get('state', None) - - -class ProductContractProperties(ProductEntityBaseParameters): - """Product profile. - - All required parameters must be populated in order to send to Azure. - - :param description: Product description. May include HTML formatting tags. - :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the product will be - presented and required to accept these terms before they can complete the subscription process. - :type terms: str - :param subscription_required: Whether a product subscription is required for accessing APIs - included in this product. If true, the product is referred to as "protected" and a valid - subscription key is required for a request to an API included in the product to succeed. If - false, the product is referred to as "open" and requests to an API included in the product can - be made without a subscription key. If property is omitted when creating a new product it's - value is assumed to be true. - :type subscription_required: bool - :param approval_required: whether subscription approval is required. If false, new - subscriptions will be approved automatically enabling developers to call the product’s APIs - immediately after subscribing. If true, administrators must manually approve the subscription - before the developer can any of the product’s APIs. Can be present only if subscriptionRequired - property is present and has a value of false. - :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can have to this product - at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present - only if subscriptionRequired property is present and has a value of false. - :type subscriptions_limit: int - :param 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". - :type state: str or ~azure.mgmt.apimanagement.models.ProductState - :param display_name: Required. Product name. - :type display_name: str - """ - - _validation = { - 'description': {'max_length': 1000, 'min_length': 0}, - 'display_name': {'required': True, 'max_length': 300, 'min_length': 1}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'terms': {'key': 'terms', 'type': 'str'}, - 'subscription_required': {'key': 'subscriptionRequired', 'type': 'bool'}, - 'approval_required': {'key': 'approvalRequired', 'type': 'bool'}, - 'subscriptions_limit': {'key': 'subscriptionsLimit', 'type': 'int'}, - 'state': {'key': 'state', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProductContractProperties, self).__init__(**kwargs) - self.display_name = kwargs['display_name'] - - -class ProductTagResourceContractProperties(ProductEntityBaseParameters): - """Product profile. - - All required parameters must be populated in order to send to Azure. - - :param description: Product description. May include HTML formatting tags. - :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the product will be - presented and required to accept these terms before they can complete the subscription process. - :type terms: str - :param subscription_required: Whether a product subscription is required for accessing APIs - included in this product. If true, the product is referred to as "protected" and a valid - subscription key is required for a request to an API included in the product to succeed. If - false, the product is referred to as "open" and requests to an API included in the product can - be made without a subscription key. If property is omitted when creating a new product it's - value is assumed to be true. - :type subscription_required: bool - :param approval_required: whether subscription approval is required. If false, new - subscriptions will be approved automatically enabling developers to call the product’s APIs - immediately after subscribing. If true, administrators must manually approve the subscription - before the developer can any of the product’s APIs. Can be present only if subscriptionRequired - property is present and has a value of false. - :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can have to this product - at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present - only if subscriptionRequired property is present and has a value of false. - :type subscriptions_limit: int - :param 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". - :type state: str or ~azure.mgmt.apimanagement.models.ProductState - :param id: Identifier of the product in the form of /products/{productId}. - :type id: str - :param name: Required. Product name. - :type name: str - """ - - _validation = { - 'description': {'max_length': 1000, 'min_length': 0}, - 'name': {'required': True, 'max_length': 300, 'min_length': 1}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'terms': {'key': 'terms', 'type': 'str'}, - 'subscription_required': {'key': 'subscriptionRequired', 'type': 'bool'}, - 'approval_required': {'key': 'approvalRequired', 'type': 'bool'}, - 'subscriptions_limit': {'key': 'subscriptionsLimit', 'type': 'int'}, - 'state': {'key': 'state', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProductTagResourceContractProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs['name'] - - -class ProductUpdateParameters(msrest.serialization.Model): - """Product Update parameters. - - :param description: Product description. May include HTML formatting tags. - :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the product will be - presented and required to accept these terms before they can complete the subscription process. - :type terms: str - :param subscription_required: Whether a product subscription is required for accessing APIs - included in this product. If true, the product is referred to as "protected" and a valid - subscription key is required for a request to an API included in the product to succeed. If - false, the product is referred to as "open" and requests to an API included in the product can - be made without a subscription key. If property is omitted when creating a new product it's - value is assumed to be true. - :type subscription_required: bool - :param approval_required: whether subscription approval is required. If false, new - subscriptions will be approved automatically enabling developers to call the product’s APIs - immediately after subscribing. If true, administrators must manually approve the subscription - before the developer can any of the product’s APIs. Can be present only if subscriptionRequired - property is present and has a value of false. - :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can have to this product - at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present - only if subscriptionRequired property is present and has a value of false. - :type subscriptions_limit: int - :param 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". - :type state: str or ~azure.mgmt.apimanagement.models.ProductState - :param display_name: Product name. - :type display_name: str - """ - - _validation = { - 'description': {'max_length': 1000, 'min_length': 0}, - 'display_name': {'max_length': 300, 'min_length': 1}, - } - - _attribute_map = { - 'description': {'key': 'properties.description', 'type': 'str'}, - 'terms': {'key': 'properties.terms', 'type': 'str'}, - 'subscription_required': {'key': 'properties.subscriptionRequired', 'type': 'bool'}, - 'approval_required': {'key': 'properties.approvalRequired', 'type': 'bool'}, - 'subscriptions_limit': {'key': 'properties.subscriptionsLimit', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProductUpdateParameters, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.terms = kwargs.get('terms', None) - self.subscription_required = kwargs.get('subscription_required', None) - self.approval_required = kwargs.get('approval_required', None) - self.subscriptions_limit = kwargs.get('subscriptions_limit', None) - self.state = kwargs.get('state', None) - self.display_name = kwargs.get('display_name', None) - - -class ProductUpdateProperties(ProductEntityBaseParameters): - """Parameters supplied to the Update Product operation. - - :param description: Product description. May include HTML formatting tags. - :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the product will be - presented and required to accept these terms before they can complete the subscription process. - :type terms: str - :param subscription_required: Whether a product subscription is required for accessing APIs - included in this product. If true, the product is referred to as "protected" and a valid - subscription key is required for a request to an API included in the product to succeed. If - false, the product is referred to as "open" and requests to an API included in the product can - be made without a subscription key. If property is omitted when creating a new product it's - value is assumed to be true. - :type subscription_required: bool - :param approval_required: whether subscription approval is required. If false, new - subscriptions will be approved automatically enabling developers to call the product’s APIs - immediately after subscribing. If true, administrators must manually approve the subscription - before the developer can any of the product’s APIs. Can be present only if subscriptionRequired - property is present and has a value of false. - :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can have to this product - at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present - only if subscriptionRequired property is present and has a value of false. - :type subscriptions_limit: int - :param 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". - :type state: str or ~azure.mgmt.apimanagement.models.ProductState - :param display_name: Product name. - :type display_name: str - """ - - _validation = { - 'description': {'max_length': 1000, 'min_length': 0}, - 'display_name': {'max_length': 300, 'min_length': 1}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'terms': {'key': 'terms', 'type': 'str'}, - 'subscription_required': {'key': 'subscriptionRequired', 'type': 'bool'}, - 'approval_required': {'key': 'approvalRequired', 'type': 'bool'}, - 'subscriptions_limit': {'key': 'subscriptionsLimit', 'type': 'int'}, - 'state': {'key': 'state', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProductUpdateProperties, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - - -class QuotaCounterCollection(msrest.serialization.Model): - """Paged Quota Counter list representation. - - :param value: Quota counter values. - :type value: list[~azure.mgmt.apimanagement.models.QuotaCounterContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[QuotaCounterContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaCounterCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class QuotaCounterContract(msrest.serialization.Model): - """Quota counter details. - - All required parameters must be populated in order to send to Azure. - - :param counter_key: Required. The Key value of the Counter. Must not be empty. - :type counter_key: str - :param period_key: Required. Identifier of the Period for which the counter was collected. Must - not be empty. - :type period_key: str - :param 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. - :type period_start_time: ~datetime.datetime - :param 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. - :type period_end_time: ~datetime.datetime - :param value: Quota Value Properties. - :type value: ~azure.mgmt.apimanagement.models.QuotaCounterValueContractProperties - """ - - _validation = { - 'counter_key': {'required': True, 'min_length': 1}, - 'period_key': {'required': True, 'min_length': 1}, - 'period_start_time': {'required': True}, - 'period_end_time': {'required': True}, - } - - _attribute_map = { - 'counter_key': {'key': 'counterKey', 'type': 'str'}, - 'period_key': {'key': 'periodKey', 'type': 'str'}, - 'period_start_time': {'key': 'periodStartTime', 'type': 'iso-8601'}, - 'period_end_time': {'key': 'periodEndTime', 'type': 'iso-8601'}, - 'value': {'key': 'value', 'type': 'QuotaCounterValueContractProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaCounterContract, self).__init__(**kwargs) - self.counter_key = kwargs['counter_key'] - self.period_key = kwargs['period_key'] - self.period_start_time = kwargs['period_start_time'] - self.period_end_time = kwargs['period_end_time'] - self.value = kwargs.get('value', None) - - -class QuotaCounterValueContract(msrest.serialization.Model): - """Quota counter value details. - - :param calls_count: Number of times Counter was called. - :type calls_count: int - :param kb_transferred: Data Transferred in KiloBytes. - :type kb_transferred: float - """ - - _attribute_map = { - 'calls_count': {'key': 'value.callsCount', 'type': 'int'}, - 'kb_transferred': {'key': 'value.kbTransferred', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaCounterValueContract, self).__init__(**kwargs) - self.calls_count = kwargs.get('calls_count', None) - self.kb_transferred = kwargs.get('kb_transferred', None) - - -class QuotaCounterValueContractProperties(msrest.serialization.Model): - """Quota counter value details. - - :param calls_count: Number of times Counter was called. - :type calls_count: int - :param kb_transferred: Data Transferred in KiloBytes. - :type kb_transferred: float - """ - - _attribute_map = { - 'calls_count': {'key': 'callsCount', 'type': 'int'}, - 'kb_transferred': {'key': 'kbTransferred', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaCounterValueContractProperties, self).__init__(**kwargs) - self.calls_count = kwargs.get('calls_count', None) - self.kb_transferred = kwargs.get('kb_transferred', None) - - -class QuotaCounterValueUpdateContract(msrest.serialization.Model): - """Quota counter value details. - - :param calls_count: Number of times Counter was called. - :type calls_count: int - :param kb_transferred: Data Transferred in KiloBytes. - :type kb_transferred: float - """ - - _attribute_map = { - 'calls_count': {'key': 'properties.callsCount', 'type': 'int'}, - 'kb_transferred': {'key': 'properties.kbTransferred', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaCounterValueUpdateContract, self).__init__(**kwargs) - self.calls_count = kwargs.get('calls_count', None) - self.kb_transferred = kwargs.get('kb_transferred', None) - - -class RecipientEmailCollection(msrest.serialization.Model): - """Paged Recipient User list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.RecipientEmailContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RecipientEmailContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RecipientEmailCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class RecipientEmailContract(Resource): - """Recipient Email details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param email: User Email subscribed to notification. - :type email: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'email': {'key': 'properties.email', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RecipientEmailContract, self).__init__(**kwargs) - self.email = kwargs.get('email', None) - - -class RecipientsContractProperties(msrest.serialization.Model): - """Notification Parameter contract. - - :param emails: List of Emails subscribed for the notification. - :type emails: list[str] - :param users: List of Users subscribed for the notification. - :type users: list[str] - """ - - _attribute_map = { - 'emails': {'key': 'emails', 'type': '[str]'}, - 'users': {'key': 'users', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(RecipientsContractProperties, self).__init__(**kwargs) - self.emails = kwargs.get('emails', None) - self.users = kwargs.get('users', None) - - -class RecipientUserCollection(msrest.serialization.Model): - """Paged Recipient User list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.RecipientUserContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RecipientUserContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RecipientUserCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class RecipientUserContract(Resource): - """Recipient User details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param user_id: API Management UserId subscribed to notification. - :type user_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_id': {'key': 'properties.userId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RecipientUserContract, self).__init__(**kwargs) - self.user_id = kwargs.get('user_id', None) - - -class RegionContract(msrest.serialization.Model): - """Region profile. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Region name. - :vartype name: str - :param is_master_region: whether Region is the master region. - :type is_master_region: bool - :param is_deleted: whether Region is deleted. - :type is_deleted: bool - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_master_region': {'key': 'isMasterRegion', 'type': 'bool'}, - 'is_deleted': {'key': 'isDeleted', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(RegionContract, self).__init__(**kwargs) - self.name = None - self.is_master_region = kwargs.get('is_master_region', None) - self.is_deleted = kwargs.get('is_deleted', None) - - -class RegionListResult(msrest.serialization.Model): - """Lists Regions operation response details. - - :param value: Lists of Regions. - :type value: list[~azure.mgmt.apimanagement.models.RegionContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RegionContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class RegistrationDelegationSettingsProperties(msrest.serialization.Model): - """User registration delegation settings properties. - - :param enabled: Enable or disable delegation for user registration. - :type enabled: bool - """ - - _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistrationDelegationSettingsProperties, self).__init__(**kwargs) - self.enabled = kwargs.get('enabled', None) - - -class ReportCollection(msrest.serialization.Model): - """Paged Report records list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.ReportRecordContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ReportRecordContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ReportCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class ReportRecordContract(msrest.serialization.Model): - """Report data. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param name: Name depending on report endpoint specifies product, API, operation or developer - name. - :type name: str - :param timestamp: Start of aggregation period. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type timestamp: ~datetime.datetime - :param interval: Length of aggregation period. Interval must be multiple of 15 minutes and may - not be zero. The value should be in ISO 8601 format - (http://en.wikipedia.org/wiki/ISO_8601#Durations). - :type interval: str - :param country: Country to which this record data is related. - :type country: str - :param region: Country region to which this record data is related. - :type region: str - :param zip: Zip code to which this record data is related. - :type zip: str - :ivar user_id: User identifier path. /users/{userId}. - :vartype user_id: str - :ivar product_id: Product identifier path. /products/{productId}. - :vartype product_id: str - :param api_id: API identifier path. /apis/{apiId}. - :type api_id: str - :param operation_id: Operation identifier path. /apis/{apiId}/operations/{operationId}. - :type operation_id: str - :param api_region: API region identifier. - :type api_region: str - :param subscription_id: Subscription identifier path. /subscriptions/{subscriptionId}. - :type subscription_id: str - :param call_count_success: Number of successful calls. This includes calls returning - HttpStatusCode <= 301 and HttpStatusCode.NotModified and HttpStatusCode.TemporaryRedirect. - :type call_count_success: int - :param call_count_blocked: Number of calls blocked due to invalid credentials. This includes - calls returning HttpStatusCode.Unauthorized and HttpStatusCode.Forbidden and - HttpStatusCode.TooManyRequests. - :type call_count_blocked: int - :param call_count_failed: Number of calls failed due to proxy or backend errors. This includes - calls returning HttpStatusCode.BadRequest(400) and any Code between - HttpStatusCode.InternalServerError (500) and 600. - :type call_count_failed: int - :param call_count_other: Number of other calls. - :type call_count_other: int - :param call_count_total: Total number of calls. - :type call_count_total: int - :param bandwidth: Bandwidth consumed. - :type bandwidth: long - :param cache_hit_count: Number of times when content was served from cache policy. - :type cache_hit_count: int - :param cache_miss_count: Number of times content was fetched from backend. - :type cache_miss_count: int - :param api_time_avg: Average time it took to process request. - :type api_time_avg: float - :param api_time_min: Minimum time it took to process request. - :type api_time_min: float - :param api_time_max: Maximum time it took to process request. - :type api_time_max: float - :param service_time_avg: Average time it took to process request on backend. - :type service_time_avg: float - :param service_time_min: Minimum time it took to process request on backend. - :type service_time_min: float - :param service_time_max: Maximum time it took to process request on backend. - :type service_time_max: float - """ - - _validation = { - 'user_id': {'readonly': True}, - 'product_id': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'interval': {'key': 'interval', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - 'region': {'key': 'region', 'type': 'str'}, - 'zip': {'key': 'zip', 'type': 'str'}, - 'user_id': {'key': 'userId', 'type': 'str'}, - 'product_id': {'key': 'productId', 'type': 'str'}, - 'api_id': {'key': 'apiId', 'type': 'str'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'api_region': {'key': 'apiRegion', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'call_count_success': {'key': 'callCountSuccess', 'type': 'int'}, - 'call_count_blocked': {'key': 'callCountBlocked', 'type': 'int'}, - 'call_count_failed': {'key': 'callCountFailed', 'type': 'int'}, - 'call_count_other': {'key': 'callCountOther', 'type': 'int'}, - 'call_count_total': {'key': 'callCountTotal', 'type': 'int'}, - 'bandwidth': {'key': 'bandwidth', 'type': '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__( - self, - **kwargs - ): - super(ReportRecordContract, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.timestamp = kwargs.get('timestamp', None) - self.interval = kwargs.get('interval', None) - self.country = kwargs.get('country', None) - self.region = kwargs.get('region', None) - self.zip = kwargs.get('zip', None) - self.user_id = None - self.product_id = None - self.api_id = kwargs.get('api_id', None) - self.operation_id = kwargs.get('operation_id', None) - self.api_region = kwargs.get('api_region', None) - self.subscription_id = kwargs.get('subscription_id', None) - self.call_count_success = kwargs.get('call_count_success', None) - self.call_count_blocked = kwargs.get('call_count_blocked', None) - self.call_count_failed = kwargs.get('call_count_failed', None) - self.call_count_other = kwargs.get('call_count_other', None) - self.call_count_total = kwargs.get('call_count_total', None) - self.bandwidth = kwargs.get('bandwidth', None) - self.cache_hit_count = kwargs.get('cache_hit_count', None) - self.cache_miss_count = kwargs.get('cache_miss_count', None) - self.api_time_avg = kwargs.get('api_time_avg', None) - self.api_time_min = kwargs.get('api_time_min', None) - self.api_time_max = kwargs.get('api_time_max', None) - self.service_time_avg = kwargs.get('service_time_avg', None) - self.service_time_min = kwargs.get('service_time_min', None) - self.service_time_max = kwargs.get('service_time_max', None) - - -class RepresentationContract(msrest.serialization.Model): - """Operation request/response representation details. - - All required parameters must be populated in order to send to Azure. - - :param content_type: Required. Specifies a registered or custom content type for this - representation, e.g. application/xml. - :type content_type: str - :param sample: An example of the representation. - :type sample: str - :param schema_id: Schema identifier. Applicable only if 'contentType' value is neither - 'application/x-www-form-urlencoded' nor 'multipart/form-data'. - :type schema_id: str - :param type_name: Type name defined by the schema. Applicable only if 'contentType' value is - neither 'application/x-www-form-urlencoded' nor 'multipart/form-data'. - :type type_name: str - :param form_parameters: Collection of form parameters. Required if 'contentType' value is - either 'application/x-www-form-urlencoded' or 'multipart/form-data'.. - :type form_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - """ - - _validation = { - 'content_type': {'required': True}, - } - - _attribute_map = { - 'content_type': {'key': 'contentType', 'type': 'str'}, - 'sample': {'key': 'sample', 'type': 'str'}, - 'schema_id': {'key': 'schemaId', 'type': 'str'}, - 'type_name': {'key': 'typeName', 'type': 'str'}, - 'form_parameters': {'key': 'formParameters', 'type': '[ParameterContract]'}, - } - - def __init__( - self, - **kwargs - ): - super(RepresentationContract, self).__init__(**kwargs) - self.content_type = kwargs['content_type'] - self.sample = kwargs.get('sample', None) - self.schema_id = kwargs.get('schema_id', None) - self.type_name = kwargs.get('type_name', None) - self.form_parameters = kwargs.get('form_parameters', None) - - -class RequestContract(msrest.serialization.Model): - """Operation request details. - - :param description: Operation request description. - :type description: str - :param query_parameters: Collection of operation request query parameters. - :type query_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :param headers: Collection of operation request headers. - :type headers: list[~azure.mgmt.apimanagement.models.ParameterContract] - :param representations: Collection of operation request representations. - :type representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] - """ - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'query_parameters': {'key': 'queryParameters', 'type': '[ParameterContract]'}, - 'headers': {'key': 'headers', 'type': '[ParameterContract]'}, - 'representations': {'key': 'representations', 'type': '[RepresentationContract]'}, - } - - def __init__( - self, - **kwargs - ): - super(RequestContract, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.query_parameters = kwargs.get('query_parameters', None) - self.headers = kwargs.get('headers', None) - self.representations = kwargs.get('representations', None) - - -class RequestReportCollection(msrest.serialization.Model): - """Paged Report records list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.RequestReportRecordContract] - :param count: Total record count number across all pages. - :type count: long - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RequestReportRecordContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(RequestReportCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - - -class RequestReportRecordContract(msrest.serialization.Model): - """Request Report data. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param api_id: API identifier path. /apis/{apiId}. - :type api_id: str - :param operation_id: Operation identifier path. /apis/{apiId}/operations/{operationId}. - :type operation_id: str - :ivar product_id: Product identifier path. /products/{productId}. - :vartype product_id: str - :ivar user_id: User identifier path. /users/{userId}. - :vartype user_id: str - :param method: The HTTP method associated with this request.. - :type method: str - :param url: The full URL associated with this request. - :type url: str - :param ip_address: The client IP address associated with this request. - :type ip_address: str - :param backend_response_code: The HTTP status code received by the gateway as a result of - forwarding this request to the backend. - :type backend_response_code: str - :param response_code: The HTTP status code returned by the gateway. - :type response_code: int - :param response_size: The size of the response returned by the gateway. - :type response_size: int - :param timestamp: The date and time when this request was received by the gateway in ISO 8601 - format. - :type timestamp: ~datetime.datetime - :param cache: Specifies if response cache was involved in generating the response. If the value - is none, the cache was not used. If the value is hit, cached response was returned. If the - value is miss, the cache was used but lookup resulted in a miss and request was fulfilled by - the backend. - :type cache: str - :param api_time: The total time it took to process this request. - :type api_time: float - :param service_time: he time it took to forward this request to the backend and get the - response back. - :type service_time: float - :param api_region: Azure region where the gateway that processed this request is located. - :type api_region: str - :param subscription_id: Subscription identifier path. /subscriptions/{subscriptionId}. - :type subscription_id: str - :param request_id: Request Identifier. - :type request_id: str - :param request_size: The size of this request.. - :type request_size: int - """ - - _validation = { - 'product_id': {'readonly': True}, - 'user_id': {'readonly': True}, - } - - _attribute_map = { - 'api_id': {'key': 'apiId', 'type': 'str'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'product_id': {'key': 'productId', 'type': 'str'}, - 'user_id': {'key': 'userId', 'type': 'str'}, - 'method': {'key': 'method', 'type': 'str'}, - 'url': {'key': 'url', 'type': 'str'}, - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'backend_response_code': {'key': 'backendResponseCode', 'type': 'str'}, - 'response_code': {'key': 'responseCode', 'type': 'int'}, - 'response_size': {'key': 'responseSize', 'type': 'int'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'cache': {'key': 'cache', 'type': 'str'}, - 'api_time': {'key': 'apiTime', 'type': 'float'}, - 'service_time': {'key': 'serviceTime', 'type': 'float'}, - 'api_region': {'key': 'apiRegion', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'request_id': {'key': 'requestId', 'type': 'str'}, - 'request_size': {'key': 'requestSize', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RequestReportRecordContract, self).__init__(**kwargs) - self.api_id = kwargs.get('api_id', None) - self.operation_id = kwargs.get('operation_id', None) - self.product_id = None - self.user_id = None - self.method = kwargs.get('method', None) - self.url = kwargs.get('url', None) - self.ip_address = kwargs.get('ip_address', None) - self.backend_response_code = kwargs.get('backend_response_code', None) - self.response_code = kwargs.get('response_code', None) - self.response_size = kwargs.get('response_size', None) - self.timestamp = kwargs.get('timestamp', None) - self.cache = kwargs.get('cache', None) - self.api_time = kwargs.get('api_time', None) - self.service_time = kwargs.get('service_time', None) - self.api_region = kwargs.get('api_region', None) - self.subscription_id = kwargs.get('subscription_id', None) - self.request_id = kwargs.get('request_id', None) - self.request_size = kwargs.get('request_size', None) - - -class ResourceLocationDataContract(msrest.serialization.Model): - """Resource location data properties. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. A canonical name for the geographic or physical location. - :type name: str - :param city: The city or locality where the resource is located. - :type city: str - :param district: The district, state, or province where the resource is located. - :type district: str - :param country_or_region: The country or region where the resource is located. - :type country_or_region: str - """ - - _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}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'district': {'key': 'district', 'type': 'str'}, - 'country_or_region': {'key': 'countryOrRegion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceLocationDataContract, self).__init__(**kwargs) - self.name = kwargs['name'] - self.city = kwargs.get('city', None) - self.district = kwargs.get('district', None) - self.country_or_region = kwargs.get('country_or_region', None) - - -class ResourceSku(msrest.serialization.Model): - """Describes an available API Management SKU. - - :param name: Name of the Sku. Possible values include: "Developer", "Standard", "Premium", - "Basic", "Consumption", "Isolated". - :type name: str or ~azure.mgmt.apimanagement.models.SkuType - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceSku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class ResourceSkuCapacity(msrest.serialization.Model): - """Describes scaling information of a SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar minimum: The minimum capacity. - :vartype minimum: int - :ivar maximum: The maximum capacity that can be set. - :vartype maximum: int - :ivar default: The default capacity. - :vartype default: int - :ivar scale_type: The scale type applicable to the sku. Possible values include: "automatic", - "manual", "none". - :vartype scale_type: str or ~azure.mgmt.apimanagement.models.ResourceSkuCapacityScaleType - """ - - _validation = { - 'minimum': {'readonly': True}, - 'maximum': {'readonly': True}, - 'default': {'readonly': True}, - 'scale_type': {'readonly': True}, - } - - _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'int'}, - 'maximum': {'key': 'maximum', 'type': 'int'}, - 'default': {'key': 'default', 'type': 'int'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceSkuCapacity, self).__init__(**kwargs) - self.minimum = None - self.maximum = None - self.default = None - self.scale_type = None - - -class ResourceSkuResult(msrest.serialization.Model): - """Describes an available API Management service SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of resource the SKU applies to. - :vartype resource_type: str - :ivar sku: Specifies API Management SKU. - :vartype sku: ~azure.mgmt.apimanagement.models.ResourceSku - :ivar capacity: Specifies the number of API Management units. - :vartype capacity: ~azure.mgmt.apimanagement.models.ResourceSkuCapacity - """ - - _validation = { - 'resource_type': {'readonly': True}, - 'sku': {'readonly': True}, - 'capacity': {'readonly': True}, - } - - _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'ResourceSku'}, - 'capacity': {'key': 'capacity', 'type': 'ResourceSkuCapacity'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceSkuResult, self).__init__(**kwargs) - self.resource_type = None - self.sku = None - self.capacity = None - - -class ResourceSkuResults(msrest.serialization.Model): - """The API Management service SKUs operation response. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The list of skus available for the service. - :type value: list[~azure.mgmt.apimanagement.models.ResourceSkuResult] - :param next_link: The uri to fetch the next page of API Management service Skus. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceSkuResult]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceSkuResults, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class ResponseContract(msrest.serialization.Model): - """Operation response details. - - All required parameters must be populated in order to send to Azure. - - :param status_code: Required. Operation response HTTP status code. - :type status_code: int - :param description: Operation response description. - :type description: str - :param representations: Collection of operation response representations. - :type representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] - :param headers: Collection of operation response headers. - :type headers: list[~azure.mgmt.apimanagement.models.ParameterContract] - """ - - _validation = { - 'status_code': {'required': True}, - } - - _attribute_map = { - 'status_code': {'key': 'statusCode', 'type': 'int'}, - 'description': {'key': 'description', 'type': 'str'}, - 'representations': {'key': 'representations', 'type': '[RepresentationContract]'}, - 'headers': {'key': 'headers', 'type': '[ParameterContract]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResponseContract, self).__init__(**kwargs) - self.status_code = kwargs['status_code'] - self.description = kwargs.get('description', None) - self.representations = kwargs.get('representations', None) - self.headers = kwargs.get('headers', None) - - -class SamplingSettings(msrest.serialization.Model): - """Sampling settings for Diagnostic. - - :param sampling_type: Sampling type. Possible values include: "fixed". - :type sampling_type: str or ~azure.mgmt.apimanagement.models.SamplingType - :param percentage: Rate of sampling for fixed-rate sampling. - :type percentage: float - """ - - _validation = { - 'percentage': {'maximum': 100, 'minimum': 0}, - } - - _attribute_map = { - 'sampling_type': {'key': 'samplingType', 'type': 'str'}, - 'percentage': {'key': 'percentage', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(SamplingSettings, self).__init__(**kwargs) - self.sampling_type = kwargs.get('sampling_type', None) - self.percentage = kwargs.get('percentage', None) - - -class SaveConfigurationParameter(msrest.serialization.Model): - """Save Tenant Configuration Contract details. - - :param branch: The name of the Git branch in which to commit the current configuration - snapshot. - :type branch: str - :param force: The value if true, the current configuration database is committed to the Git - repository, even if the Git repository has newer changes that would be overwritten. - :type force: bool - """ - - _attribute_map = { - 'branch': {'key': 'properties.branch', 'type': 'str'}, - 'force': {'key': 'properties.force', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SaveConfigurationParameter, self).__init__(**kwargs) - self.branch = kwargs.get('branch', None) - self.force = kwargs.get('force', None) - - -class SchemaCollection(msrest.serialization.Model): - """The response of the list schema operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Api Schema Contract value. - :vartype value: list[~azure.mgmt.apimanagement.models.SchemaContract] - :param count: Total record count number. - :type count: long - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SchemaContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SchemaCollection, self).__init__(**kwargs) - self.value = None - self.count = kwargs.get('count', None) - self.next_link = None - - -class SchemaContract(Resource): - """Schema Contract details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param content_type: Must be a valid a media type used in a Content-Type header as defined in - the RFC 2616. Media type of the schema document (e.g. application/json, application/xml).
- - ``Swagger`` Schema use ``application/vnd.ms-azure-apim.swagger.definitions+json``
- - ``WSDL`` Schema use ``application/vnd.ms-azure-apim.xsd+xml``
- ``OpenApi`` Schema use - ``application/vnd.oai.openapi.components+json``
- ``WADL Schema`` use - ``application/vnd.ms-azure-apim.wadl.grammars+xml``. - :type content_type: str - :param value: Json escaped string defining the document representing the Schema. Used for - schemas other than Swagger/OpenAPI. - :type value: str - :param definitions: Types definitions. Used for Swagger/OpenAPI schemas only, null otherwise. - :type definitions: any - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'content_type': {'key': 'properties.contentType', 'type': 'str'}, - 'value': {'key': 'properties.document.value', 'type': 'str'}, - 'definitions': {'key': 'properties.document.definitions', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(SchemaContract, self).__init__(**kwargs) - self.content_type = kwargs.get('content_type', None) - self.value = kwargs.get('value', None) - self.definitions = kwargs.get('definitions', None) - - -class SubscriptionCollection(msrest.serialization.Model): - """Paged Subscriptions list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.SubscriptionContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SubscriptionContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class SubscriptionContract(Resource): - """Subscription details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param owner_id: The user resource identifier of the subscription owner. The value is a valid - relative URL in the format of /users/{userId} where {userId} is a user identifier. - :type owner_id: str - :param scope: Scope like /products/{productId} or /apis or /apis/{apiId}. - :type scope: str - :param display_name: The name of the subscription, or null if the subscription has no name. - :type display_name: str - :param state: Subscription state. Possible states are * active – the subscription is active, * - suspended – the subscription is blocked, and the subscriber cannot call any APIs of the - product, * submitted – the subscription request has been made by the developer, but has not yet - been approved or rejected, * rejected – the subscription request has been denied by an - administrator, * cancelled – the subscription has been cancelled by the developer or - administrator, * expired – the subscription reached its expiration date and was deactivated. - Possible values include: "suspended", "active", "expired", "submitted", "rejected", - "cancelled". - :type 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 - :param start_date: Subscription activation date. The setting is for audit purposes only and the - subscription is not automatically activated. The subscription lifecycle can be managed by using - the ``state`` property. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as - specified by the ISO 8601 standard. - :type start_date: ~datetime.datetime - :param expiration_date: Subscription expiration date. The setting is for audit purposes only - and the subscription is not automatically expired. The subscription lifecycle can be managed by - using the ``state`` property. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type expiration_date: ~datetime.datetime - :param end_date: Date when subscription was cancelled or expired. The setting is for audit - purposes only and the subscription is not automatically cancelled. The subscription lifecycle - can be managed by using the ``state`` property. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type end_date: ~datetime.datetime - :param notification_date: Upcoming subscription expiration notification date. The date conforms - to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type notification_date: ~datetime.datetime - :param primary_key: Subscription primary key. This property will not be filled on 'GET' - operations! Use '/listSecrets' POST request to get the value. - :type primary_key: str - :param secondary_key: Subscription secondary key. This property will not be filled on 'GET' - operations! Use '/listSecrets' POST request to get the value. - :type secondary_key: str - :param state_comment: Optional subscription comment added by an administrator when the state is - changed to the 'rejected'. - :type state_comment: str - :param allow_tracing: Determines whether tracing is enabled. - :type allow_tracing: bool - """ - - _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'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionContract, self).__init__(**kwargs) - self.owner_id = kwargs.get('owner_id', None) - self.scope = kwargs.get('scope', None) - self.display_name = kwargs.get('display_name', None) - self.state = kwargs.get('state', None) - self.created_date = None - self.start_date = kwargs.get('start_date', None) - self.expiration_date = kwargs.get('expiration_date', None) - self.end_date = kwargs.get('end_date', None) - self.notification_date = kwargs.get('notification_date', None) - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - self.state_comment = kwargs.get('state_comment', None) - self.allow_tracing = kwargs.get('allow_tracing', None) - - -class SubscriptionCreateParameters(msrest.serialization.Model): - """Subscription create details. - - :param owner_id: User (user id path) for whom subscription is being created in form - /users/{userId}. - :type owner_id: str - :param scope: Scope like /products/{productId} or /apis or /apis/{apiId}. - :type scope: str - :param display_name: Subscription name. - :type display_name: str - :param primary_key: Primary subscription key. If not specified during request key will be - generated automatically. - :type primary_key: str - :param secondary_key: Secondary subscription key. If not specified during request key will be - generated automatically. - :type secondary_key: str - :param state: Initial subscription state. If no value is specified, subscription is created - with Submitted state. Possible states are * active – the subscription is active, * suspended – - the subscription is blocked, and the subscriber cannot call any APIs of the product, * - submitted – the subscription request has been made by the developer, but has not yet been - approved or rejected, * rejected – the subscription request has been denied by an - administrator, * cancelled – the subscription has been cancelled by the developer or - administrator, * expired – the subscription reached its expiration date and was deactivated. - Possible values include: "suspended", "active", "expired", "submitted", "rejected", - "cancelled". - :type state: str or ~azure.mgmt.apimanagement.models.SubscriptionState - :param allow_tracing: Determines whether tracing can be enabled. - :type allow_tracing: bool - """ - - _validation = { - 'display_name': {'max_length': 100, 'min_length': 1}, - 'primary_key': {'max_length': 256, 'min_length': 1}, - 'secondary_key': {'max_length': 256, 'min_length': 1}, - } - - _attribute_map = { - 'owner_id': {'key': 'properties.ownerId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'primary_key': {'key': 'properties.primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'properties.secondaryKey', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'allow_tracing': {'key': 'properties.allowTracing', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionCreateParameters, self).__init__(**kwargs) - self.owner_id = kwargs.get('owner_id', None) - self.scope = kwargs.get('scope', None) - self.display_name = kwargs.get('display_name', None) - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - self.state = kwargs.get('state', None) - self.allow_tracing = kwargs.get('allow_tracing', None) - - -class SubscriptionKeyParameterNamesContract(msrest.serialization.Model): - """Subscription key parameter names details. - - :param header: Subscription key header name. - :type header: str - :param query: Subscription key query string parameter name. - :type query: str - """ - - _attribute_map = { - 'header': {'key': 'header', 'type': 'str'}, - 'query': {'key': 'query', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionKeyParameterNamesContract, self).__init__(**kwargs) - self.header = kwargs.get('header', None) - self.query = kwargs.get('query', None) - - -class SubscriptionKeysContract(msrest.serialization.Model): - """Subscription keys. - - :param primary_key: Subscription primary key. - :type primary_key: str - :param secondary_key: Subscription secondary key. - :type secondary_key: str - """ - - _validation = { - 'primary_key': {'max_length': 256, 'min_length': 1}, - 'secondary_key': {'max_length': 256, 'min_length': 1}, - } - - _attribute_map = { - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionKeysContract, self).__init__(**kwargs) - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - - -class SubscriptionsDelegationSettingsProperties(msrest.serialization.Model): - """Subscriptions delegation settings properties. - - :param enabled: Enable or disable delegation for subscriptions. - :type enabled: bool - """ - - _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionsDelegationSettingsProperties, self).__init__(**kwargs) - self.enabled = kwargs.get('enabled', None) - - -class SubscriptionUpdateParameters(msrest.serialization.Model): - """Subscription update details. - - :param owner_id: User identifier path: /users/{userId}. - :type owner_id: str - :param scope: Scope like /products/{productId} or /apis or /apis/{apiId}. - :type scope: str - :param expiration_date: Subscription expiration date. The setting is for audit purposes only - and the subscription is not automatically expired. The subscription lifecycle can be managed by - using the ``state`` property. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type expiration_date: ~datetime.datetime - :param display_name: Subscription name. - :type display_name: str - :param primary_key: Primary subscription key. - :type primary_key: str - :param secondary_key: Secondary subscription key. - :type secondary_key: str - :param state: Subscription state. Possible states are * active – the subscription is active, * - suspended – the subscription is blocked, and the subscriber cannot call any APIs of the - product, * submitted – the subscription request has been made by the developer, but has not yet - been approved or rejected, * rejected – the subscription request has been denied by an - administrator, * cancelled – the subscription has been cancelled by the developer or - administrator, * expired – the subscription reached its expiration date and was deactivated. - Possible values include: "suspended", "active", "expired", "submitted", "rejected", - "cancelled". - :type state: str or ~azure.mgmt.apimanagement.models.SubscriptionState - :param state_comment: Comments describing subscription state change by the administrator when - the state is changed to the 'rejected'. - :type state_comment: str - :param allow_tracing: Determines whether tracing can be enabled. - :type allow_tracing: bool - """ - - _validation = { - 'primary_key': {'max_length': 256, 'min_length': 1}, - 'secondary_key': {'max_length': 256, 'min_length': 1}, - } - - _attribute_map = { - 'owner_id': {'key': 'properties.ownerId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'primary_key': {'key': 'properties.primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'properties.secondaryKey', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'state_comment': {'key': 'properties.stateComment', 'type': 'str'}, - 'allow_tracing': {'key': 'properties.allowTracing', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionUpdateParameters, self).__init__(**kwargs) - self.owner_id = kwargs.get('owner_id', None) - self.scope = kwargs.get('scope', None) - self.expiration_date = kwargs.get('expiration_date', None) - self.display_name = kwargs.get('display_name', None) - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - self.state = kwargs.get('state', None) - self.state_comment = kwargs.get('state_comment', None) - self.allow_tracing = kwargs.get('allow_tracing', None) - - -class TagCollection(msrest.serialization.Model): - """Paged Tag list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.TagContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[TagContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TagCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class TagContract(Resource): - """Tag Contract details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param display_name: Tag name. - :type display_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'max_length': 160, 'min_length': 1}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TagContract, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - - -class TagCreateUpdateParameters(msrest.serialization.Model): - """Parameters supplied to Create/Update Tag operations. - - :param display_name: Tag name. - :type display_name: str - """ - - _validation = { - 'display_name': {'max_length': 160, 'min_length': 1}, - } - - _attribute_map = { - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TagCreateUpdateParameters, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - - -class TagDescriptionBaseProperties(msrest.serialization.Model): - """Parameters supplied to the Create TagDescription operation. - - :param description: Description of the Tag. - :type description: str - :param external_docs_url: Absolute URL of external resources describing the tag. - :type external_docs_url: str - :param external_docs_description: Description of the external resources describing the tag. - :type external_docs_description: str - """ - - _validation = { - 'external_docs_url': {'max_length': 2000, 'min_length': 0}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'external_docs_url': {'key': 'externalDocsUrl', 'type': 'str'}, - 'external_docs_description': {'key': 'externalDocsDescription', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TagDescriptionBaseProperties, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.external_docs_url = kwargs.get('external_docs_url', None) - self.external_docs_description = kwargs.get('external_docs_description', None) - - -class TagDescriptionCollection(msrest.serialization.Model): - """Paged TagDescription list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.TagDescriptionContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[TagDescriptionContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TagDescriptionCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class TagDescriptionContract(Resource): - """Contract details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param description: Description of the Tag. - :type description: str - :param external_docs_url: Absolute URL of external resources describing the tag. - :type external_docs_url: str - :param external_docs_description: Description of the external resources describing the tag. - :type external_docs_description: str - :param tag_id: Identifier of the tag in the form of /tags/{tagId}. - :type tag_id: str - :param display_name: Tag name. - :type display_name: str - """ - - _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}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'external_docs_url': {'key': 'properties.externalDocsUrl', 'type': 'str'}, - 'external_docs_description': {'key': 'properties.externalDocsDescription', 'type': 'str'}, - 'tag_id': {'key': 'properties.tagId', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TagDescriptionContract, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.external_docs_url = kwargs.get('external_docs_url', None) - self.external_docs_description = kwargs.get('external_docs_description', None) - self.tag_id = kwargs.get('tag_id', None) - self.display_name = kwargs.get('display_name', None) - - -class TagDescriptionContractProperties(TagDescriptionBaseProperties): - """TagDescription contract Properties. - - :param description: Description of the Tag. - :type description: str - :param external_docs_url: Absolute URL of external resources describing the tag. - :type external_docs_url: str - :param external_docs_description: Description of the external resources describing the tag. - :type external_docs_description: str - :param tag_id: Identifier of the tag in the form of /tags/{tagId}. - :type tag_id: str - :param display_name: Tag name. - :type display_name: str - """ - - _validation = { - 'external_docs_url': {'max_length': 2000, 'min_length': 0}, - 'display_name': {'max_length': 160, 'min_length': 1}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'external_docs_url': {'key': 'externalDocsUrl', 'type': 'str'}, - 'external_docs_description': {'key': 'externalDocsDescription', 'type': 'str'}, - 'tag_id': {'key': 'tagId', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TagDescriptionContractProperties, self).__init__(**kwargs) - self.tag_id = kwargs.get('tag_id', None) - self.display_name = kwargs.get('display_name', None) - - -class TagDescriptionCreateParameters(msrest.serialization.Model): - """Parameters supplied to the Create TagDescription operation. - - :param description: Description of the Tag. - :type description: str - :param external_docs_url: Absolute URL of external resources describing the tag. - :type external_docs_url: str - :param external_docs_description: Description of the external resources describing the tag. - :type external_docs_description: str - """ - - _validation = { - 'external_docs_url': {'max_length': 2000, 'min_length': 0}, - } - - _attribute_map = { - 'description': {'key': 'properties.description', 'type': 'str'}, - 'external_docs_url': {'key': 'properties.externalDocsUrl', 'type': 'str'}, - 'external_docs_description': {'key': 'properties.externalDocsDescription', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TagDescriptionCreateParameters, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.external_docs_url = kwargs.get('external_docs_url', None) - self.external_docs_description = kwargs.get('external_docs_description', None) - - -class TagResourceCollection(msrest.serialization.Model): - """Paged Tag list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.TagResourceContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[TagResourceContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TagResourceCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class TagResourceContract(msrest.serialization.Model): - """TagResource contract properties. - - All required parameters must be populated in order to send to Azure. - - :param tag: Required. Tag associated with the resource. - :type tag: ~azure.mgmt.apimanagement.models.TagResourceContractProperties - :param api: Api associated with the tag. - :type api: ~azure.mgmt.apimanagement.models.ApiTagResourceContractProperties - :param operation: Operation associated with the tag. - :type operation: ~azure.mgmt.apimanagement.models.OperationTagResourceContractProperties - :param product: Product associated with the tag. - :type product: ~azure.mgmt.apimanagement.models.ProductTagResourceContractProperties - """ - - _validation = { - 'tag': {'required': True}, - } - - _attribute_map = { - 'tag': {'key': 'tag', 'type': 'TagResourceContractProperties'}, - 'api': {'key': 'api', 'type': 'ApiTagResourceContractProperties'}, - 'operation': {'key': 'operation', 'type': 'OperationTagResourceContractProperties'}, - 'product': {'key': 'product', 'type': 'ProductTagResourceContractProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(TagResourceContract, self).__init__(**kwargs) - self.tag = kwargs['tag'] - self.api = kwargs.get('api', None) - self.operation = kwargs.get('operation', None) - self.product = kwargs.get('product', None) - - -class TagResourceContractProperties(msrest.serialization.Model): - """Contract defining the Tag property in the Tag Resource Contract. - - :param id: Tag identifier. - :type id: str - :param name: Tag Name. - :type name: str - """ - - _validation = { - 'name': {'max_length': 160, 'min_length': 1}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TagResourceContractProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - - -class TenantConfigurationSyncStateContract(msrest.serialization.Model): - """Result of Tenant Configuration Sync State. - - :param branch: The name of Git branch. - :type branch: str - :param commit_id: The latest commit Id. - :type commit_id: str - :param is_export: value indicating if last sync was save (true) or deploy (false) operation. - :type is_export: bool - :param is_synced: value indicating if last synchronization was later than the configuration - change. - :type is_synced: bool - :param is_git_enabled: value indicating whether Git configuration access is enabled. - :type is_git_enabled: bool - :param sync_date: The date of the latest synchronization. The date conforms to the following - format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type sync_date: ~datetime.datetime - :param configuration_change_date: The date of the latest configuration change. The date - conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 - standard. - :type configuration_change_date: ~datetime.datetime - :param last_operation_id: Most recent tenant configuration operation identifier. - :type last_operation_id: str - """ - - _attribute_map = { - 'branch': {'key': 'properties.branch', 'type': 'str'}, - 'commit_id': {'key': 'properties.commitId', 'type': 'str'}, - 'is_export': {'key': 'properties.isExport', 'type': 'bool'}, - 'is_synced': {'key': 'properties.isSynced', 'type': 'bool'}, - 'is_git_enabled': {'key': 'properties.isGitEnabled', 'type': 'bool'}, - 'sync_date': {'key': 'properties.syncDate', 'type': 'iso-8601'}, - 'configuration_change_date': {'key': 'properties.configurationChangeDate', 'type': 'iso-8601'}, - 'last_operation_id': {'key': 'properties.lastOperationId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TenantConfigurationSyncStateContract, self).__init__(**kwargs) - self.branch = kwargs.get('branch', None) - self.commit_id = kwargs.get('commit_id', None) - self.is_export = kwargs.get('is_export', None) - self.is_synced = kwargs.get('is_synced', None) - self.is_git_enabled = kwargs.get('is_git_enabled', None) - self.sync_date = kwargs.get('sync_date', None) - self.configuration_change_date = kwargs.get('configuration_change_date', None) - self.last_operation_id = kwargs.get('last_operation_id', None) - - -class TenantSettingsCollection(msrest.serialization.Model): - """Paged AccessInformation list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.TenantSettingsContract] - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[TenantSettingsContract]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TenantSettingsCollection, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class TenantSettingsContract(Resource): - """Tenant Settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param settings: Tenant settings. - :type settings: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'settings': {'key': 'properties.settings', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TenantSettingsContract, self).__init__(**kwargs) - self.settings = kwargs.get('settings', None) - - -class TermsOfServiceProperties(msrest.serialization.Model): - """Terms of service contract properties. - - :param text: A terms of service text. - :type text: str - :param enabled: Display terms of service during a sign-up process. - :type enabled: bool - :param consent_required: Ask user for consent to the terms of service. - :type consent_required: bool - """ - - _attribute_map = { - 'text': {'key': 'text', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'consent_required': {'key': 'consentRequired', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(TermsOfServiceProperties, self).__init__(**kwargs) - self.text = kwargs.get('text', None) - self.enabled = kwargs.get('enabled', None) - self.consent_required = kwargs.get('consent_required', None) - - -class TokenBodyParameterContract(msrest.serialization.Model): - """OAuth acquire token request body parameter (www-url-form-encoded). - - All required parameters must be populated in order to send to Azure. - - :param name: Required. body parameter name. - :type name: str - :param value: Required. body parameter value. - :type value: str - """ - - _validation = { - 'name': {'required': True}, - 'value': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TokenBodyParameterContract, self).__init__(**kwargs) - self.name = kwargs['name'] - self.value = kwargs['value'] - - -class UserCollection(msrest.serialization.Model): - """Paged Users list representation. - - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.UserContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[UserContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class UserContract(Resource): - """User details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param 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". - :type state: str or ~azure.mgmt.apimanagement.models.UserState - :param note: Optional note about a user set by the administrator. - :type note: str - :param identities: Collection of user identities. - :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :param first_name: First name. - :type first_name: str - :param last_name: Last name. - :type last_name: str - :param email: Email address. - :type email: str - :param registration_date: Date of user registration. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type registration_date: ~datetime.datetime - :ivar groups: Collection of groups user is part of. - :vartype groups: list[~azure.mgmt.apimanagement.models.GroupContractProperties] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'groups': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'note': {'key': 'properties.note', 'type': 'str'}, - 'identities': {'key': 'properties.identities', 'type': '[UserIdentityContract]'}, - 'first_name': {'key': 'properties.firstName', 'type': 'str'}, - 'last_name': {'key': 'properties.lastName', 'type': 'str'}, - 'email': {'key': 'properties.email', 'type': 'str'}, - 'registration_date': {'key': 'properties.registrationDate', 'type': 'iso-8601'}, - 'groups': {'key': 'properties.groups', 'type': '[GroupContractProperties]'}, - } - - def __init__( - self, - **kwargs - ): - super(UserContract, self).__init__(**kwargs) - self.state = kwargs.get('state', "active") - self.note = kwargs.get('note', None) - self.identities = kwargs.get('identities', None) - self.first_name = kwargs.get('first_name', None) - self.last_name = kwargs.get('last_name', None) - self.email = kwargs.get('email', None) - self.registration_date = kwargs.get('registration_date', None) - self.groups = None - - -class UserEntityBaseParameters(msrest.serialization.Model): - """User Entity Base Parameters set. - - :param 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". - :type state: str or ~azure.mgmt.apimanagement.models.UserState - :param note: Optional note about a user set by the administrator. - :type note: str - :param identities: Collection of user identities. - :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - """ - - _attribute_map = { - 'state': {'key': 'state', 'type': 'str'}, - 'note': {'key': 'note', 'type': 'str'}, - 'identities': {'key': 'identities', 'type': '[UserIdentityContract]'}, - } - - def __init__( - self, - **kwargs - ): - super(UserEntityBaseParameters, self).__init__(**kwargs) - self.state = kwargs.get('state', "active") - self.note = kwargs.get('note', None) - self.identities = kwargs.get('identities', None) - - -class UserContractProperties(UserEntityBaseParameters): - """User profile. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param 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". - :type state: str or ~azure.mgmt.apimanagement.models.UserState - :param note: Optional note about a user set by the administrator. - :type note: str - :param identities: Collection of user identities. - :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :param first_name: First name. - :type first_name: str - :param last_name: Last name. - :type last_name: str - :param email: Email address. - :type email: str - :param registration_date: Date of user registration. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type registration_date: ~datetime.datetime - :ivar groups: Collection of groups user is part of. - :vartype groups: list[~azure.mgmt.apimanagement.models.GroupContractProperties] - """ - - _validation = { - 'groups': {'readonly': True}, - } - - _attribute_map = { - 'state': {'key': 'state', 'type': 'str'}, - 'note': {'key': 'note', 'type': 'str'}, - 'identities': {'key': 'identities', 'type': '[UserIdentityContract]'}, - 'first_name': {'key': 'firstName', 'type': 'str'}, - 'last_name': {'key': 'lastName', 'type': 'str'}, - 'email': {'key': 'email', 'type': 'str'}, - 'registration_date': {'key': 'registrationDate', 'type': 'iso-8601'}, - 'groups': {'key': 'groups', 'type': '[GroupContractProperties]'}, - } - - def __init__( - self, - **kwargs - ): - super(UserContractProperties, self).__init__(**kwargs) - self.first_name = kwargs.get('first_name', None) - self.last_name = kwargs.get('last_name', None) - self.email = kwargs.get('email', None) - self.registration_date = kwargs.get('registration_date', None) - self.groups = None - - -class UserCreateParameterProperties(UserEntityBaseParameters): - """Parameters supplied to the Create User operation. - - All required parameters must be populated in order to send to Azure. - - :param 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". - :type state: str or ~azure.mgmt.apimanagement.models.UserState - :param note: Optional note about a user set by the administrator. - :type note: str - :param identities: Collection of user identities. - :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :param email: Required. Email address. Must not be empty and must be unique within the service - instance. - :type email: str - :param first_name: Required. First name. - :type first_name: str - :param last_name: Required. Last name. - :type last_name: str - :param password: User Password. If no value is provided, a default password is generated. - :type password: str - :param app_type: Determines the type of application which send the create user request. Default - is legacy portal. Possible values include: "portal", "developerPortal". - :type app_type: str or ~azure.mgmt.apimanagement.models.AppType - :param confirmation: Determines the type of confirmation e-mail that will be sent to the newly - created user. Possible values include: "signup", "invite". - :type confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation - """ - - _validation = { - 'email': {'required': True, 'max_length': 254, 'min_length': 1}, - 'first_name': {'required': True, 'max_length': 100, 'min_length': 1}, - 'last_name': {'required': True, 'max_length': 100, 'min_length': 1}, - } - - _attribute_map = { - 'state': {'key': 'state', 'type': 'str'}, - 'note': {'key': 'note', 'type': 'str'}, - 'identities': {'key': 'identities', 'type': '[UserIdentityContract]'}, - 'email': {'key': 'email', 'type': 'str'}, - 'first_name': {'key': 'firstName', 'type': 'str'}, - 'last_name': {'key': 'lastName', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'app_type': {'key': 'appType', 'type': 'str'}, - 'confirmation': {'key': 'confirmation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserCreateParameterProperties, self).__init__(**kwargs) - self.email = kwargs['email'] - self.first_name = kwargs['first_name'] - self.last_name = kwargs['last_name'] - self.password = kwargs.get('password', None) - self.app_type = kwargs.get('app_type', None) - self.confirmation = kwargs.get('confirmation', None) - - -class UserCreateParameters(msrest.serialization.Model): - """User create details. - - :param 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". - :type state: str or ~azure.mgmt.apimanagement.models.UserState - :param note: Optional note about a user set by the administrator. - :type note: str - :param identities: Collection of user identities. - :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :param email: Email address. Must not be empty and must be unique within the service instance. - :type email: str - :param first_name: First name. - :type first_name: str - :param last_name: Last name. - :type last_name: str - :param password: User Password. If no value is provided, a default password is generated. - :type password: str - :param app_type: Determines the type of application which send the create user request. Default - is legacy portal. Possible values include: "portal", "developerPortal". - :type app_type: str or ~azure.mgmt.apimanagement.models.AppType - :param confirmation: Determines the type of confirmation e-mail that will be sent to the newly - created user. Possible values include: "signup", "invite". - :type confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation - """ - - _validation = { - 'email': {'max_length': 254, 'min_length': 1}, - 'first_name': {'max_length': 100, 'min_length': 1}, - 'last_name': {'max_length': 100, 'min_length': 1}, - } - - _attribute_map = { - 'state': {'key': 'properties.state', 'type': 'str'}, - 'note': {'key': 'properties.note', 'type': 'str'}, - 'identities': {'key': 'properties.identities', 'type': '[UserIdentityContract]'}, - 'email': {'key': 'properties.email', 'type': 'str'}, - 'first_name': {'key': 'properties.firstName', 'type': 'str'}, - 'last_name': {'key': 'properties.lastName', 'type': 'str'}, - 'password': {'key': 'properties.password', 'type': 'str'}, - 'app_type': {'key': 'properties.appType', 'type': 'str'}, - 'confirmation': {'key': 'properties.confirmation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserCreateParameters, self).__init__(**kwargs) - self.state = kwargs.get('state', "active") - self.note = kwargs.get('note', None) - self.identities = kwargs.get('identities', None) - self.email = kwargs.get('email', None) - self.first_name = kwargs.get('first_name', None) - self.last_name = kwargs.get('last_name', None) - self.password = kwargs.get('password', None) - self.app_type = kwargs.get('app_type', None) - self.confirmation = kwargs.get('confirmation', None) - - -class UserIdentityCollection(msrest.serialization.Model): - """List of Users Identity list representation. - - :param value: User Identity values. - :type value: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[UserIdentityContract]'}, - 'count': {'key': 'count', 'type': 'long'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserIdentityCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = kwargs.get('count', None) - self.next_link = kwargs.get('next_link', None) - - -class UserIdentityContract(msrest.serialization.Model): - """User identity details. - - :param provider: Identity provider name. - :type provider: str - :param id: Identifier value within provider. - :type id: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserIdentityContract, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.id = kwargs.get('id', None) - - -class UserIdentityProperties(msrest.serialization.Model): - """UserIdentityProperties. - - :param principal_id: The principal id of user assigned identity. - :type principal_id: str - :param client_id: The client id of user assigned identity. - :type client_id: str - """ - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserIdentityProperties, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.client_id = kwargs.get('client_id', None) - - -class UserTokenParameters(msrest.serialization.Model): - """Get User Token parameters. - - :param key_type: The Key to be used to generate token for user. Possible values include: - "primary", "secondary". - :type key_type: str or ~azure.mgmt.apimanagement.models.KeyType - :param 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. - :type expiry: ~datetime.datetime - """ - - _attribute_map = { - 'key_type': {'key': 'properties.keyType', 'type': 'str'}, - 'expiry': {'key': 'properties.expiry', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(UserTokenParameters, self).__init__(**kwargs) - self.key_type = kwargs.get('key_type', None) - self.expiry = kwargs.get('expiry', None) - - -class UserTokenResult(msrest.serialization.Model): - """Get User Token response details. - - :param value: Shared Access Authorization token for the User. - :type value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserTokenResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class UserUpdateParameters(msrest.serialization.Model): - """User update parameters. - - :param 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". - :type state: str or ~azure.mgmt.apimanagement.models.UserState - :param note: Optional note about a user set by the administrator. - :type note: str - :param identities: Collection of user identities. - :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :param email: Email address. Must not be empty and must be unique within the service instance. - :type email: str - :param password: User Password. - :type password: str - :param first_name: First name. - :type first_name: str - :param last_name: Last name. - :type last_name: str - """ - - _validation = { - 'email': {'max_length': 254, 'min_length': 1}, - 'first_name': {'max_length': 100, 'min_length': 1}, - 'last_name': {'max_length': 100, 'min_length': 1}, - } - - _attribute_map = { - 'state': {'key': 'properties.state', 'type': 'str'}, - 'note': {'key': 'properties.note', 'type': 'str'}, - 'identities': {'key': 'properties.identities', 'type': '[UserIdentityContract]'}, - 'email': {'key': 'properties.email', 'type': 'str'}, - 'password': {'key': 'properties.password', 'type': 'str'}, - 'first_name': {'key': 'properties.firstName', 'type': 'str'}, - 'last_name': {'key': 'properties.lastName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserUpdateParameters, self).__init__(**kwargs) - self.state = kwargs.get('state', "active") - self.note = kwargs.get('note', None) - self.identities = kwargs.get('identities', None) - self.email = kwargs.get('email', None) - self.password = kwargs.get('password', None) - self.first_name = kwargs.get('first_name', None) - self.last_name = kwargs.get('last_name', None) - - -class UserUpdateParametersProperties(UserEntityBaseParameters): - """Parameters supplied to the Update User operation. - - :param 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". - :type state: str or ~azure.mgmt.apimanagement.models.UserState - :param note: Optional note about a user set by the administrator. - :type note: str - :param identities: Collection of user identities. - :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :param email: Email address. Must not be empty and must be unique within the service instance. - :type email: str - :param password: User Password. - :type password: str - :param first_name: First name. - :type first_name: str - :param last_name: Last name. - :type last_name: str - """ - - _validation = { - 'email': {'max_length': 254, 'min_length': 1}, - 'first_name': {'max_length': 100, 'min_length': 1}, - 'last_name': {'max_length': 100, 'min_length': 1}, - } - - _attribute_map = { - 'state': {'key': 'state', 'type': 'str'}, - 'note': {'key': 'note', 'type': 'str'}, - 'identities': {'key': 'identities', 'type': '[UserIdentityContract]'}, - 'email': {'key': 'email', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'first_name': {'key': 'firstName', 'type': 'str'}, - 'last_name': {'key': 'lastName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserUpdateParametersProperties, self).__init__(**kwargs) - self.email = kwargs.get('email', None) - self.password = kwargs.get('password', None) - self.first_name = kwargs.get('first_name', None) - self.last_name = kwargs.get('last_name', None) - - -class VirtualNetworkConfiguration(msrest.serialization.Model): - """Configuration of a virtual network to which API Management service is deployed. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar vnetid: The virtual network ID. This is typically a GUID. Expect a null GUID by default. - :vartype vnetid: str - :ivar subnetname: The name of the subnet. - :vartype subnetname: str - :param subnet_resource_id: The full resource ID of a subnet in a virtual network to deploy the - API Management service in. - :type subnet_resource_id: str - """ - - _validation = { - 'vnetid': {'readonly': True}, - 'subnetname': {'readonly': True}, - 'subnet_resource_id': {'pattern': r'^/subscriptions/[^/]*/resourceGroups/[^/]*/providers/Microsoft.(ClassicNetwork|Network)/virtualNetworks/[^/]*/subnets/[^/]*$'}, - } - - _attribute_map = { - 'vnetid': {'key': 'vnetid', 'type': 'str'}, - 'subnetname': {'key': 'subnetname', 'type': 'str'}, - 'subnet_resource_id': {'key': 'subnetResourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualNetworkConfiguration, self).__init__(**kwargs) - self.vnetid = None - self.subnetname = None - self.subnet_resource_id = kwargs.get('subnet_resource_id', None) - - -class X509CertificateName(msrest.serialization.Model): - """Properties of server X509Names. - - :param name: Common Name of the Certificate. - :type name: str - :param issuer_certificate_thumbprint: Thumbprint for the Issuer of the Certificate. - :type issuer_certificate_thumbprint: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'issuer_certificate_thumbprint': {'key': 'issuerCertificateThumbprint', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(X509CertificateName, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.issuer_certificate_thumbprint = kwargs.get('issuer_certificate_thumbprint', None) 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 33a0d73038980..54a3af9cfb7da 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 @@ -22,8 +22,8 @@ class AccessInformationCollection(msrest.serialization.Model): :ivar value: Page values. :vartype value: list[~azure.mgmt.apimanagement.models.AccessInformationContract] - :param count: Total record count number across all pages. - :type count: long + :ivar count: Total record count number across all pages. + :vartype count: long :ivar next_link: Next page link if any. :vartype next_link: str """ @@ -45,6 +45,10 @@ def __init__( count: Optional[int] = None, **kwargs ): + """ + :keyword count: Total record count number across all pages. + :paramtype count: long + """ super(AccessInformationCollection, self).__init__(**kwargs) self.value = None self.count = count @@ -52,15 +56,17 @@ def __init__( class Resource(msrest.serialization.Model): - """The Resource definition. + """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str """ @@ -80,6 +86,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -91,18 +99,20 @@ class AccessInformationContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param id_properties_id: Access Information type ('access' or 'gitAccess'). - :type id_properties_id: str - :param principal_id: Principal (User) Identifier. - :type principal_id: str - :param enabled: Determines whether direct access is enabled. - :type enabled: bool + :ivar id_properties_id: Access Information type ('access' or 'gitAccess'). + :vartype id_properties_id: str + :ivar principal_id: Principal (User) Identifier. + :vartype principal_id: str + :ivar enabled: Determines whether direct access is enabled. + :vartype enabled: bool """ _validation = { @@ -128,6 +138,14 @@ def __init__( enabled: Optional[bool] = None, **kwargs ): + """ + :keyword id_properties_id: Access Information type ('access' or 'gitAccess'). + :paramtype id_properties_id: str + :keyword principal_id: Principal (User) Identifier. + :paramtype principal_id: str + :keyword enabled: Determines whether direct access is enabled. + :paramtype enabled: bool + """ super(AccessInformationContract, self).__init__(**kwargs) self.id_properties_id = id_properties_id self.principal_id = principal_id @@ -137,16 +155,16 @@ def __init__( class AccessInformationCreateParameters(msrest.serialization.Model): """Tenant access information update parameters. - :param principal_id: Principal (User) Identifier. - :type principal_id: str - :param primary_key: Primary access key. This property will not be filled on 'GET' operations! + :ivar principal_id: Principal (User) Identifier. + :vartype principal_id: str + :ivar primary_key: Primary access key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. - :type primary_key: str - :param secondary_key: Secondary access key. This property will not be filled on 'GET' + :vartype primary_key: str + :ivar secondary_key: Secondary access key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. - :type secondary_key: str - :param enabled: Determines whether direct access is enabled. - :type enabled: bool + :vartype secondary_key: str + :ivar enabled: Determines whether direct access is enabled. + :vartype enabled: bool """ _attribute_map = { @@ -165,6 +183,18 @@ def __init__( enabled: Optional[bool] = None, **kwargs ): + """ + :keyword principal_id: Principal (User) Identifier. + :paramtype principal_id: str + :keyword primary_key: Primary access key. This property will not be filled on 'GET' operations! + Use '/listSecrets' POST request to get the value. + :paramtype primary_key: str + :keyword secondary_key: Secondary access key. This property will not be filled on 'GET' + operations! Use '/listSecrets' POST request to get the value. + :paramtype secondary_key: str + :keyword enabled: Determines whether direct access is enabled. + :paramtype enabled: bool + """ super(AccessInformationCreateParameters, self).__init__(**kwargs) self.principal_id = principal_id self.primary_key = primary_key @@ -175,18 +205,18 @@ def __init__( class AccessInformationSecretsContract(msrest.serialization.Model): """Tenant access information contract of the API Management service. - :param id: Access Information type ('access' or 'gitAccess'). - :type id: str - :param principal_id: Principal (User) Identifier. - :type principal_id: str - :param primary_key: Primary access key. This property will not be filled on 'GET' operations! + :ivar id: Access Information type ('access' or 'gitAccess'). + :vartype id: str + :ivar principal_id: Principal (User) Identifier. + :vartype principal_id: str + :ivar primary_key: Primary access key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. - :type primary_key: str - :param secondary_key: Secondary access key. This property will not be filled on 'GET' + :vartype primary_key: str + :ivar secondary_key: Secondary access key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. - :type secondary_key: str - :param enabled: Determines whether direct access is enabled. - :type enabled: bool + :vartype secondary_key: str + :ivar enabled: Determines whether direct access is enabled. + :vartype enabled: bool """ _attribute_map = { @@ -207,6 +237,20 @@ def __init__( enabled: Optional[bool] = None, **kwargs ): + """ + :keyword id: Access Information type ('access' or 'gitAccess'). + :paramtype id: str + :keyword principal_id: Principal (User) Identifier. + :paramtype principal_id: str + :keyword primary_key: Primary access key. This property will not be filled on 'GET' operations! + Use '/listSecrets' POST request to get the value. + :paramtype primary_key: str + :keyword secondary_key: Secondary access key. This property will not be filled on 'GET' + operations! Use '/listSecrets' POST request to get the value. + :paramtype secondary_key: str + :keyword enabled: Determines whether direct access is enabled. + :paramtype enabled: bool + """ super(AccessInformationSecretsContract, self).__init__(**kwargs) self.id = id self.principal_id = principal_id @@ -218,8 +262,8 @@ def __init__( class AccessInformationUpdateParameters(msrest.serialization.Model): """Tenant access information update parameters. - :param enabled: Determines whether direct access is enabled. - :type enabled: bool + :ivar enabled: Determines whether direct access is enabled. + :vartype enabled: bool """ _attribute_map = { @@ -232,6 +276,10 @@ def __init__( enabled: Optional[bool] = None, **kwargs ): + """ + :keyword enabled: Determines whether direct access is enabled. + :paramtype enabled: bool + """ super(AccessInformationUpdateParameters, self).__init__(**kwargs) self.enabled = enabled @@ -243,13 +291,13 @@ class AdditionalLocation(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The location name of the additional region among Azure Data center + :ivar location: Required. The location name of the additional region among Azure Data center regions. - :type location: str - :param sku: Required. SKU properties of the API Management service. - :type sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties - :param zones: A list of availability zones denoting where the resource needs to come from. - :type zones: list[str] + :vartype location: str + :ivar sku: Required. SKU properties of the API Management service. + :vartype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties + :ivar zones: A list of availability zones denoting where the resource needs to come from. + :vartype zones: list[str] :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management service in the additional location. Available only for Basic, Standard, Premium and Isolated SKU. @@ -258,14 +306,21 @@ class AdditionalLocation(msrest.serialization.Model): service which is deployed in an Internal Virtual Network in a particular additional location. Available only for Basic, Standard, Premium and Isolated SKU. :vartype private_ip_addresses: list[str] - :param virtual_network_configuration: Virtual network configuration for the location. - :type virtual_network_configuration: + :ivar public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with + Virtual Network deployed service in the location. Supported only for Premium SKU being deployed + in Virtual Network. + :vartype public_ip_address_id: str + :ivar virtual_network_configuration: Virtual network configuration for the location. + :vartype virtual_network_configuration: ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :ivar gateway_regional_url: Gateway URL of the API Management service in the Region. :vartype gateway_regional_url: str - :param disable_gateway: Property only valid for an Api Management service deployed in multiple + :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. - :type disable_gateway: bool + :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 ~azure.mgmt.apimanagement.models.PlatformVersion """ _validation = { @@ -274,6 +329,7 @@ class AdditionalLocation(msrest.serialization.Model): 'public_ip_addresses': {'readonly': True}, 'private_ip_addresses': {'readonly': True}, 'gateway_regional_url': {'readonly': True}, + 'platform_version': {'readonly': True}, } _attribute_map = { @@ -282,9 +338,11 @@ class AdditionalLocation(msrest.serialization.Model): '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__( @@ -293,30 +351,52 @@ def __init__( location: str, sku: "ApiManagementServiceSkuProperties", zones: Optional[List[str]] = None, + public_ip_address_id: Optional[str] = None, virtual_network_configuration: Optional["VirtualNetworkConfiguration"] = None, disable_gateway: Optional[bool] = False, **kwargs ): + """ + :keyword location: Required. The location name of the additional region among Azure Data center + regions. + :paramtype location: str + :keyword sku: Required. SKU properties of the API Management service. + :paramtype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties + :keyword zones: A list of availability zones denoting where the resource needs to come from. + :paramtype zones: list[str] + :keyword public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with + Virtual Network deployed service in the location. Supported only for Premium SKU being deployed + in Virtual Network. + :paramtype public_ip_address_id: str + :keyword virtual_network_configuration: Virtual network configuration for the location. + :paramtype virtual_network_configuration: + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration + :keyword 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) self.location = location self.sku = sku self.zones = zones self.public_ip_addresses = None self.private_ip_addresses = None + self.public_ip_address_id = public_ip_address_id self.virtual_network_configuration = virtual_network_configuration self.gateway_regional_url = None self.disable_gateway = disable_gateway + self.platform_version = None class ApiCollection(msrest.serialization.Model): - """Paged Api list representation. + """Paged API list representation. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Page values. :vartype value: list[~azure.mgmt.apimanagement.models.ApiContract] - :param count: Total record count number across all pages. - :type count: long + :ivar count: Total record count number across all pages. + :vartype count: long :ivar next_link: Next page link if any. :vartype next_link: str """ @@ -338,65 +418,120 @@ def __init__( count: Optional[int] = None, **kwargs ): + """ + :keyword count: Total record count number across all pages. + :paramtype count: long + """ super(ApiCollection, self).__init__(**kwargs) self.value = None self.count = count self.next_link = None +class ApiContactInformation(msrest.serialization.Model): + """API contact information. + + :ivar name: The identifying name of the contact person/organization. + :vartype name: str + :ivar url: The URL pointing to the contact information. MUST be in the format of a URL. + :vartype url: str + :ivar email: The email address of the contact person/organization. MUST be in the format of an + email address. + :vartype email: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'url': {'key': 'url', 'type': 'str'}, + 'email': {'key': 'email', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + url: Optional[str] = None, + email: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The identifying name of the contact person/organization. + :paramtype name: str + :keyword url: The URL pointing to the contact information. MUST be in the format of a URL. + :paramtype url: str + :keyword email: The email address of the contact person/organization. MUST be in the format of + an email address. + :paramtype email: str + """ + super(ApiContactInformation, self).__init__(**kwargs) + self.name = name + self.url = url + self.email = email + + class ApiContract(Resource): - """Api details. + """API details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param description: Description of the API. May include HTML formatting tags. - :type description: str - :param authentication_settings: Collection of authentication settings included into this API. - :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made available. - :type subscription_key_parameter_names: + :ivar description: Description of the API. May include HTML formatting tags. + :vartype description: str + :ivar authentication_settings: Collection of authentication settings included into this API. + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :ivar subscription_key_parameter_names: Protocols over which API is made available. + :vartype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: "http", "soap". - :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is provided, default + :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "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. - :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API is versioned. - :type api_version: str - :param is_current: Indicates if API revision is current api revision. - :type is_current: bool + :vartype api_revision: str + :ivar api_version: Indicates the version identifier of the API if the API is versioned. + :vartype api_version: str + :ivar is_current: Indicates if API revision is current api revision. + :vartype is_current: bool :ivar is_online: Indicates if API revision is accessible via the gateway. :vartype is_online: bool - :param api_revision_description: Description of the Api Revision. - :type api_revision_description: str - :param api_version_description: Description of the Api Version. - :type api_version_description: str - :param api_version_set_id: A resource identifier for the related ApiVersionSet. - :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product subscription is required for + :ivar api_revision_description: Description of the API Revision. + :vartype api_revision_description: str + :ivar api_version_description: Description of the API Version. + :vartype api_version_description: str + :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. + :vartype api_version_set_id: str + :ivar subscription_required: Specifies whether an API or Product subscription is required for accessing the API. - :type subscription_required: bool - :param source_api_id: API identifier of the source API. - :type source_api_id: str - :param display_name: API name. Must be 1 to 300 characters long. - :type display_name: str - :param service_url: Absolute URL of the backend service implementing this API. Cannot be more + :vartype subscription_required: bool + :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of + a URL. + :vartype terms_of_service_url: str + :ivar contact: Contact information for the API. + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :ivar license: License information for the API. + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + :ivar source_api_id: API identifier of the source API. + :vartype source_api_id: str + :ivar display_name: API name. Must be 1 to 300 characters long. + :vartype display_name: str + :ivar service_url: Absolute URL of the backend service implementing this API. Cannot be more than 2000 characters long. - :type service_url: str - :param 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. - :type path: str - :param protocols: Describes on which protocols the operations in this API can be invoked. - :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - :param api_version_set: Version set details. - :type api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :vartype service_url: str + :ivar path: Relative URL uniquely identifying this API and all of its resource paths within the + API Management service instance. It is appended to the API endpoint base URL specified during + the service instance creation to form a public URL for this API. + :vartype path: str + :ivar protocols: Describes on which protocols the operations in this API can be invoked. + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + :ivar api_version_set: Version set details. + :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ _validation = { @@ -429,6 +564,9 @@ class ApiContract(Resource): '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'}, @@ -451,6 +589,9 @@ def __init__( api_version_description: Optional[str] = None, api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, + terms_of_service_url: Optional[str] = None, + contact: Optional["ApiContactInformation"] = None, + license: Optional["ApiLicenseInformation"] = None, source_api_id: Optional[str] = None, display_name: Optional[str] = None, service_url: Optional[str] = None, @@ -459,6 +600,57 @@ def __init__( api_version_set: Optional["ApiVersionSetContractDetails"] = None, **kwargs ): + """ + :keyword description: Description of the API. May include HTML formatting tags. + :paramtype description: str + :keyword authentication_settings: Collection of authentication settings included into this API. + :paramtype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :keyword subscription_key_parameter_names: Protocols over which API is made available. + :paramtype subscription_key_parameter_names: + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", + "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 + :keyword api_version: Indicates the version identifier of the API if the API is versioned. + :paramtype api_version: str + :keyword is_current: Indicates if API revision is current api revision. + :paramtype is_current: bool + :keyword api_revision_description: Description of the API Revision. + :paramtype api_revision_description: str + :keyword api_version_description: Description of the API Version. + :paramtype api_version_description: str + :keyword api_version_set_id: A resource identifier for the related ApiVersionSet. + :paramtype api_version_set_id: str + :keyword subscription_required: Specifies whether an API or Product subscription is required + for accessing the API. + :paramtype subscription_required: bool + :keyword terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format + of a URL. + :paramtype terms_of_service_url: str + :keyword contact: Contact information for the API. + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :keyword license: License information for the API. + :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + :keyword source_api_id: API identifier of the source API. + :paramtype source_api_id: str + :keyword display_name: API name. Must be 1 to 300 characters long. + :paramtype display_name: str + :keyword service_url: Absolute URL of the backend service implementing this API. Cannot be more + than 2000 characters long. + :paramtype service_url: str + :keyword path: Relative URL uniquely identifying this API and all of its resource paths within + the API Management service instance. It is appended to the API endpoint base URL specified + during the service instance creation to form a public URL for this API. + :paramtype path: str + :keyword protocols: Describes on which protocols the operations in this API can be invoked. + :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + :keyword api_version_set: Version set details. + :paramtype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + """ super(ApiContract, self).__init__(**kwargs) self.description = description self.authentication_settings = authentication_settings @@ -472,6 +664,9 @@ def __init__( self.api_version_description = api_version_description self.api_version_set_id = api_version_set_id self.subscription_required = subscription_required + self.terms_of_service_url = terms_of_service_url + self.contact = contact + self.license = license self.source_api_id = source_api_id self.display_name = display_name self.service_url = service_url @@ -485,33 +680,41 @@ class ApiEntityBaseContract(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the API. May include HTML formatting tags. - :type description: str - :param authentication_settings: Collection of authentication settings included into this API. - :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made available. - :type subscription_key_parameter_names: + :ivar description: Description of the API. May include HTML formatting tags. + :vartype description: str + :ivar authentication_settings: Collection of authentication settings included into this API. + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :ivar subscription_key_parameter_names: Protocols over which API is made available. + :vartype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: "http", "soap". - :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is provided, default + :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "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. - :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API is versioned. - :type api_version: str - :param is_current: Indicates if API revision is current api revision. - :type is_current: bool + :vartype api_revision: str + :ivar api_version: Indicates the version identifier of the API if the API is versioned. + :vartype api_version: str + :ivar is_current: Indicates if API revision is current api revision. + :vartype is_current: bool :ivar is_online: Indicates if API revision is accessible via the gateway. :vartype is_online: bool - :param api_revision_description: Description of the Api Revision. - :type api_revision_description: str - :param api_version_description: Description of the Api Version. - :type api_version_description: str - :param api_version_set_id: A resource identifier for the related ApiVersionSet. - :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product subscription is required for + :ivar api_revision_description: Description of the API Revision. + :vartype api_revision_description: str + :ivar api_version_description: Description of the API Version. + :vartype api_version_description: str + :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. + :vartype api_version_set_id: str + :ivar subscription_required: Specifies whether an API or Product subscription is required for accessing the API. - :type subscription_required: bool + :vartype subscription_required: bool + :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of + a URL. + :vartype terms_of_service_url: str + :ivar contact: Contact information for the API. + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :ivar license: License information for the API. + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation """ _validation = { @@ -535,6 +738,9 @@ class ApiEntityBaseContract(msrest.serialization.Model): '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__( @@ -551,8 +757,47 @@ def __init__( api_version_description: Optional[str] = None, api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, - **kwargs - ): + terms_of_service_url: Optional[str] = None, + contact: Optional["ApiContactInformation"] = None, + license: Optional["ApiLicenseInformation"] = None, + **kwargs + ): + """ + :keyword description: Description of the API. May include HTML formatting tags. + :paramtype description: str + :keyword authentication_settings: Collection of authentication settings included into this API. + :paramtype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :keyword subscription_key_parameter_names: Protocols over which API is made available. + :paramtype subscription_key_parameter_names: + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", + "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 + :keyword api_version: Indicates the version identifier of the API if the API is versioned. + :paramtype api_version: str + :keyword is_current: Indicates if API revision is current api revision. + :paramtype is_current: bool + :keyword api_revision_description: Description of the API Revision. + :paramtype api_revision_description: str + :keyword api_version_description: Description of the API Version. + :paramtype api_version_description: str + :keyword api_version_set_id: A resource identifier for the related ApiVersionSet. + :paramtype api_version_set_id: str + :keyword subscription_required: Specifies whether an API or Product subscription is required + for accessing the API. + :paramtype subscription_required: bool + :keyword terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format + of a URL. + :paramtype terms_of_service_url: str + :keyword contact: Contact information for the API. + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :keyword license: License information for the API. + :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + """ super(ApiEntityBaseContract, self).__init__(**kwargs) self.description = description self.authentication_settings = authentication_settings @@ -566,57 +811,68 @@ def __init__( self.api_version_description = api_version_description self.api_version_set_id = api_version_set_id self.subscription_required = subscription_required + self.terms_of_service_url = terms_of_service_url + self.contact = contact + self.license = license class ApiContractProperties(ApiEntityBaseContract): - """Api Entity Properties. + """API Entity Properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param description: Description of the API. May include HTML formatting tags. - :type description: str - :param authentication_settings: Collection of authentication settings included into this API. - :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made available. - :type subscription_key_parameter_names: + :ivar description: Description of the API. May include HTML formatting tags. + :vartype description: str + :ivar authentication_settings: Collection of authentication settings included into this API. + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :ivar subscription_key_parameter_names: Protocols over which API is made available. + :vartype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: "http", "soap". - :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is provided, default + :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "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. - :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API is versioned. - :type api_version: str - :param is_current: Indicates if API revision is current api revision. - :type is_current: bool + :vartype api_revision: str + :ivar api_version: Indicates the version identifier of the API if the API is versioned. + :vartype api_version: str + :ivar is_current: Indicates if API revision is current api revision. + :vartype is_current: bool :ivar is_online: Indicates if API revision is accessible via the gateway. :vartype is_online: bool - :param api_revision_description: Description of the Api Revision. - :type api_revision_description: str - :param api_version_description: Description of the Api Version. - :type api_version_description: str - :param api_version_set_id: A resource identifier for the related ApiVersionSet. - :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product subscription is required for + :ivar api_revision_description: Description of the API Revision. + :vartype api_revision_description: str + :ivar api_version_description: Description of the API Version. + :vartype api_version_description: str + :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. + :vartype api_version_set_id: str + :ivar subscription_required: Specifies whether an API or Product subscription is required for accessing the API. - :type subscription_required: bool - :param source_api_id: API identifier of the source API. - :type source_api_id: str - :param display_name: API name. Must be 1 to 300 characters long. - :type display_name: str - :param service_url: Absolute URL of the backend service implementing this API. Cannot be more + :vartype subscription_required: bool + :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of + a URL. + :vartype terms_of_service_url: str + :ivar contact: Contact information for the API. + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :ivar license: License information for the API. + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + :ivar source_api_id: API identifier of the source API. + :vartype source_api_id: str + :ivar display_name: API name. Must be 1 to 300 characters long. + :vartype display_name: str + :ivar service_url: Absolute URL of the backend service implementing this API. Cannot be more than 2000 characters long. - :type service_url: str - :param path: Required. Relative URL uniquely identifying this API and all of its resource paths + :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. - :type path: str - :param protocols: Describes on which protocols the operations in this API can be invoked. - :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - :param api_version_set: Version set details. - :type api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :vartype path: str + :ivar protocols: Describes on which protocols the operations in this API can be invoked. + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + :ivar api_version_set: Version set details. + :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ _validation = { @@ -643,6 +899,9 @@ class ApiContractProperties(ApiEntityBaseContract): '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'}, @@ -666,6 +925,9 @@ def __init__( api_version_description: Optional[str] = None, api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, + terms_of_service_url: Optional[str] = None, + contact: Optional["ApiContactInformation"] = None, + license: Optional["ApiLicenseInformation"] = None, source_api_id: Optional[str] = None, display_name: Optional[str] = None, service_url: Optional[str] = None, @@ -673,7 +935,58 @@ def __init__( api_version_set: Optional["ApiVersionSetContractDetails"] = None, **kwargs ): - 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, **kwargs) + """ + :keyword description: Description of the API. May include HTML formatting tags. + :paramtype description: str + :keyword authentication_settings: Collection of authentication settings included into this API. + :paramtype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :keyword subscription_key_parameter_names: Protocols over which API is made available. + :paramtype subscription_key_parameter_names: + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", + "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 + :keyword api_version: Indicates the version identifier of the API if the API is versioned. + :paramtype api_version: str + :keyword is_current: Indicates if API revision is current api revision. + :paramtype is_current: bool + :keyword api_revision_description: Description of the API Revision. + :paramtype api_revision_description: str + :keyword api_version_description: Description of the API Version. + :paramtype api_version_description: str + :keyword api_version_set_id: A resource identifier for the related ApiVersionSet. + :paramtype api_version_set_id: str + :keyword subscription_required: Specifies whether an API or Product subscription is required + for accessing the API. + :paramtype subscription_required: bool + :keyword terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format + of a URL. + :paramtype terms_of_service_url: str + :keyword contact: Contact information for the API. + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :keyword license: License information for the API. + :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + :keyword source_api_id: API identifier of the source API. + :paramtype source_api_id: str + :keyword display_name: API name. Must be 1 to 300 characters long. + :paramtype display_name: str + :keyword service_url: Absolute URL of the backend service implementing this API. Cannot be more + than 2000 characters long. + :paramtype service_url: str + :keyword path: 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. + :paramtype path: str + :keyword protocols: Describes on which protocols the operations in this API can be invoked. + :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + :keyword api_version_set: Version set details. + :paramtype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + """ + super(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) self.source_api_id = source_api_id self.display_name = display_name self.service_url = service_url @@ -687,43 +1000,51 @@ class ApiContractUpdateProperties(ApiEntityBaseContract): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the API. May include HTML formatting tags. - :type description: str - :param authentication_settings: Collection of authentication settings included into this API. - :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made available. - :type subscription_key_parameter_names: + :ivar description: Description of the API. May include HTML formatting tags. + :vartype description: str + :ivar authentication_settings: Collection of authentication settings included into this API. + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :ivar subscription_key_parameter_names: Protocols over which API is made available. + :vartype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: "http", "soap". - :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is provided, default + :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "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. - :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API is versioned. - :type api_version: str - :param is_current: Indicates if API revision is current api revision. - :type is_current: bool + :vartype api_revision: str + :ivar api_version: Indicates the version identifier of the API if the API is versioned. + :vartype api_version: str + :ivar is_current: Indicates if API revision is current api revision. + :vartype is_current: bool :ivar is_online: Indicates if API revision is accessible via the gateway. :vartype is_online: bool - :param api_revision_description: Description of the Api Revision. - :type api_revision_description: str - :param api_version_description: Description of the Api Version. - :type api_version_description: str - :param api_version_set_id: A resource identifier for the related ApiVersionSet. - :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product subscription is required for + :ivar api_revision_description: Description of the API Revision. + :vartype api_revision_description: str + :ivar api_version_description: Description of the API Version. + :vartype api_version_description: str + :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. + :vartype api_version_set_id: str + :ivar subscription_required: Specifies whether an API or Product subscription is required for accessing the API. - :type subscription_required: bool - :param display_name: API name. - :type display_name: str - :param service_url: Absolute URL of the backend service implementing this API. - :type service_url: str - :param 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. - :type path: str - :param protocols: Describes on which protocols the operations in this API can be invoked. - :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + :vartype subscription_required: bool + :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of + a URL. + :vartype terms_of_service_url: str + :ivar contact: Contact information for the API. + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :ivar license: License information for the API. + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + :ivar display_name: API name. + :vartype display_name: str + :ivar service_url: Absolute URL of the backend service implementing this API. + :vartype service_url: str + :ivar path: Relative URL uniquely identifying this API and all of its resource paths within the + API Management service instance. It is appended to the API endpoint base URL specified during + the service instance creation to form a public URL for this API. + :vartype path: str + :ivar protocols: Describes on which protocols the operations in this API can be invoked. + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] """ _validation = { @@ -750,6 +1071,9 @@ class ApiContractUpdateProperties(ApiEntityBaseContract): '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'}, @@ -770,13 +1094,62 @@ def __init__( api_version_description: Optional[str] = None, api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, + terms_of_service_url: Optional[str] = None, + contact: Optional["ApiContactInformation"] = None, + license: Optional["ApiLicenseInformation"] = None, display_name: Optional[str] = None, service_url: Optional[str] = None, path: Optional[str] = None, protocols: Optional[List[Union[str, "Protocol"]]] = None, **kwargs ): - 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, **kwargs) + """ + :keyword description: Description of the API. May include HTML formatting tags. + :paramtype description: str + :keyword authentication_settings: Collection of authentication settings included into this API. + :paramtype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :keyword subscription_key_parameter_names: Protocols over which API is made available. + :paramtype subscription_key_parameter_names: + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", + "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 + :keyword api_version: Indicates the version identifier of the API if the API is versioned. + :paramtype api_version: str + :keyword is_current: Indicates if API revision is current api revision. + :paramtype is_current: bool + :keyword api_revision_description: Description of the API Revision. + :paramtype api_revision_description: str + :keyword api_version_description: Description of the API Version. + :paramtype api_version_description: str + :keyword api_version_set_id: A resource identifier for the related ApiVersionSet. + :paramtype api_version_set_id: str + :keyword subscription_required: Specifies whether an API or Product subscription is required + for accessing the API. + :paramtype subscription_required: bool + :keyword terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format + of a URL. + :paramtype terms_of_service_url: str + :keyword contact: Contact information for the API. + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :keyword license: License information for the API. + :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + :keyword display_name: API name. + :paramtype display_name: str + :keyword service_url: Absolute URL of the backend service implementing this API. + :paramtype service_url: str + :keyword path: Relative URL uniquely identifying this API and all of its resource paths within + the API Management service instance. It is appended to the API endpoint base URL specified + during the service instance creation to form a public URL for this API. + :paramtype path: str + :keyword protocols: Describes on which protocols the operations in this API can be invoked. + :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + """ + super(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) self.display_name = display_name self.service_url = service_url self.path = path @@ -788,62 +1161,74 @@ class ApiCreateOrUpdateParameter(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the API. May include HTML formatting tags. - :type description: str - :param authentication_settings: Collection of authentication settings included into this API. - :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made available. - :type subscription_key_parameter_names: + :ivar description: Description of the API. May include HTML formatting tags. + :vartype description: str + :ivar authentication_settings: Collection of authentication settings included into this API. + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :ivar subscription_key_parameter_names: Protocols over which API is made available. + :vartype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: "http", "soap". - :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is provided, default + :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "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. - :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API is versioned. - :type api_version: str - :param is_current: Indicates if API revision is current api revision. - :type is_current: bool + :vartype api_revision: str + :ivar api_version: Indicates the version identifier of the API if the API is versioned. + :vartype api_version: str + :ivar is_current: Indicates if API revision is current api revision. + :vartype is_current: bool :ivar is_online: Indicates if API revision is accessible via the gateway. :vartype is_online: bool - :param api_revision_description: Description of the Api Revision. - :type api_revision_description: str - :param api_version_description: Description of the Api Version. - :type api_version_description: str - :param api_version_set_id: A resource identifier for the related ApiVersionSet. - :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product subscription is required for + :ivar api_revision_description: Description of the API Revision. + :vartype api_revision_description: str + :ivar api_version_description: Description of the API Version. + :vartype api_version_description: str + :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. + :vartype api_version_set_id: str + :ivar subscription_required: Specifies whether an API or Product subscription is required for accessing the API. - :type subscription_required: bool - :param source_api_id: API identifier of the source API. - :type source_api_id: str - :param display_name: API name. Must be 1 to 300 characters long. - :type display_name: str - :param service_url: Absolute URL of the backend service implementing this API. Cannot be more + :vartype subscription_required: bool + :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of + a URL. + :vartype terms_of_service_url: str + :ivar contact: Contact information for the API. + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :ivar license: License information for the API. + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + :ivar source_api_id: API identifier of the source API. + :vartype source_api_id: str + :ivar display_name: API name. Must be 1 to 300 characters long. + :vartype display_name: str + :ivar service_url: Absolute URL of the backend service implementing this API. Cannot be more than 2000 characters long. - :type service_url: str - :param 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. - :type path: str - :param protocols: Describes on which protocols the operations in this API can be invoked. - :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - :param api_version_set: Version set details. - :type api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails - :param value: Content value when Importing an API. - :type value: str - :param format: Format of the Content in which the API is getting imported. Possible values + :vartype service_url: str + :ivar path: Relative URL uniquely identifying this API and all of its resource paths within the + API Management service instance. It is appended to the API endpoint base URL specified during + the service instance creation to form a public URL for this API. + :vartype path: str + :ivar protocols: Describes on which protocols the operations in this API can be invoked. + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + :ivar api_version_set: Version set details. + :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :ivar 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". - :type format: str or ~azure.mgmt.apimanagement.models.ContentFormat - :param wsdl_selector: Criteria to limit import of WSDL to a subset of the document. - :type wsdl_selector: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector - :param soap_api_type: Type of Api to create. + "wsdl-link", "openapi", "openapi+json", "openapi-link", "openapi+json-link", "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: + ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector + :ivar soap_api_type: Type of API to create. - * ``http`` creates a SOAP to REST API - * ``soap`` creates a SOAP pass-through API . Possible values include: "http", "soap". - :type soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType + * ``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". + :vartype soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType """ _validation = { @@ -870,6 +1255,9 @@ class ApiCreateOrUpdateParameter(msrest.serialization.Model): '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'}, @@ -896,6 +1284,9 @@ def __init__( api_version_description: Optional[str] = None, api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, + terms_of_service_url: Optional[str] = None, + contact: Optional["ApiContactInformation"] = None, + license: Optional["ApiLicenseInformation"] = None, source_api_id: Optional[str] = None, display_name: Optional[str] = None, service_url: Optional[str] = None, @@ -908,6 +1299,75 @@ def __init__( soap_api_type: Optional[Union[str, "SoapApiType"]] = None, **kwargs ): + """ + :keyword description: Description of the API. May include HTML formatting tags. + :paramtype description: str + :keyword authentication_settings: Collection of authentication settings included into this API. + :paramtype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :keyword subscription_key_parameter_names: Protocols over which API is made available. + :paramtype subscription_key_parameter_names: + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", + "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 + :keyword api_version: Indicates the version identifier of the API if the API is versioned. + :paramtype api_version: str + :keyword is_current: Indicates if API revision is current api revision. + :paramtype is_current: bool + :keyword api_revision_description: Description of the API Revision. + :paramtype api_revision_description: str + :keyword api_version_description: Description of the API Version. + :paramtype api_version_description: str + :keyword api_version_set_id: A resource identifier for the related ApiVersionSet. + :paramtype api_version_set_id: str + :keyword subscription_required: Specifies whether an API or Product subscription is required + for accessing the API. + :paramtype subscription_required: bool + :keyword terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format + of a URL. + :paramtype terms_of_service_url: str + :keyword contact: Contact information for the API. + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :keyword license: License information for the API. + :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + :keyword source_api_id: API identifier of the source API. + :paramtype source_api_id: str + :keyword display_name: API name. Must be 1 to 300 characters long. + :paramtype display_name: str + :keyword service_url: Absolute URL of the backend service implementing this API. Cannot be more + than 2000 characters long. + :paramtype service_url: str + :keyword path: Relative URL uniquely identifying this API and all of its resource paths within + the API Management service instance. It is appended to the API endpoint base URL specified + during the service instance creation to form a public URL for this API. + :paramtype path: str + :keyword protocols: Describes on which protocols the operations in this API can be invoked. + :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + :keyword api_version_set: Version set details. + :paramtype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :keyword value: Content value when Importing an API. + :paramtype value: str + :keyword format: Format of the Content in which the API is getting imported. 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 ~azure.mgmt.apimanagement.models.ContentFormat + :keyword wsdl_selector: Criteria to limit import of WSDL to a subset of the document. + :paramtype wsdl_selector: + ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector + :keyword soap_api_type: Type of API to create. + + + * ``http`` creates a REST API + * ``soap`` creates a SOAP pass-through API + * ``websocket`` creates websocket API + * ``graphql`` creates GraphQL API. Possible values include: "http", "soap", "websocket", + "graphql". + :paramtype soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType + """ super(ApiCreateOrUpdateParameter, self).__init__(**kwargs) self.description = description self.authentication_settings = authentication_settings @@ -921,6 +1381,9 @@ def __init__( self.api_version_description = api_version_description self.api_version_set_id = api_version_set_id self.subscription_required = subscription_required + self.terms_of_service_url = terms_of_service_url + self.contact = contact + self.license = license self.source_api_id = source_api_id self.display_name = display_name self.service_url = service_url @@ -934,68 +1397,80 @@ def __init__( class ApiCreateOrUpdateProperties(ApiContractProperties): - """Api Create or Update Properties. + """API Create or Update Properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param description: Description of the API. May include HTML formatting tags. - :type description: str - :param authentication_settings: Collection of authentication settings included into this API. - :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made available. - :type subscription_key_parameter_names: + :ivar description: Description of the API. May include HTML formatting tags. + :vartype description: str + :ivar authentication_settings: Collection of authentication settings included into this API. + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :ivar subscription_key_parameter_names: Protocols over which API is made available. + :vartype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: "http", "soap". - :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is provided, default + :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "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. - :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API is versioned. - :type api_version: str - :param is_current: Indicates if API revision is current api revision. - :type is_current: bool + :vartype api_revision: str + :ivar api_version: Indicates the version identifier of the API if the API is versioned. + :vartype api_version: str + :ivar is_current: Indicates if API revision is current api revision. + :vartype is_current: bool :ivar is_online: Indicates if API revision is accessible via the gateway. :vartype is_online: bool - :param api_revision_description: Description of the Api Revision. - :type api_revision_description: str - :param api_version_description: Description of the Api Version. - :type api_version_description: str - :param api_version_set_id: A resource identifier for the related ApiVersionSet. - :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product subscription is required for + :ivar api_revision_description: Description of the API Revision. + :vartype api_revision_description: str + :ivar api_version_description: Description of the API Version. + :vartype api_version_description: str + :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. + :vartype api_version_set_id: str + :ivar subscription_required: Specifies whether an API or Product subscription is required for accessing the API. - :type subscription_required: bool - :param source_api_id: API identifier of the source API. - :type source_api_id: str - :param display_name: API name. Must be 1 to 300 characters long. - :type display_name: str - :param service_url: Absolute URL of the backend service implementing this API. Cannot be more + :vartype subscription_required: bool + :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of + a URL. + :vartype terms_of_service_url: str + :ivar contact: Contact information for the API. + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :ivar license: License information for the API. + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + :ivar source_api_id: API identifier of the source API. + :vartype source_api_id: str + :ivar display_name: API name. Must be 1 to 300 characters long. + :vartype display_name: str + :ivar service_url: Absolute URL of the backend service implementing this API. Cannot be more than 2000 characters long. - :type service_url: str - :param path: Required. Relative URL uniquely identifying this API and all of its resource paths + :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. - :type path: str - :param protocols: Describes on which protocols the operations in this API can be invoked. - :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - :param api_version_set: Version set details. - :type api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails - :param value: Content value when Importing an API. - :type value: str - :param format: Format of the Content in which the API is getting imported. Possible values + :vartype path: str + :ivar protocols: Describes on which protocols the operations in this API can be invoked. + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + :ivar api_version_set: Version set details. + :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :ivar 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". - :type format: str or ~azure.mgmt.apimanagement.models.ContentFormat - :param wsdl_selector: Criteria to limit import of WSDL to a subset of the document. - :type wsdl_selector: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector - :param soap_api_type: Type of Api to create. + "wsdl-link", "openapi", "openapi+json", "openapi-link", "openapi+json-link", "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: + ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector + :ivar soap_api_type: Type of API to create. - * ``http`` creates a SOAP to REST API - * ``soap`` creates a SOAP pass-through API . Possible values include: "http", "soap". - :type soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType + * ``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". + :vartype soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType """ _validation = { @@ -1022,6 +1497,9 @@ class ApiCreateOrUpdateProperties(ApiContractProperties): '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'}, @@ -1049,6 +1527,9 @@ def __init__( api_version_description: Optional[str] = None, api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, + terms_of_service_url: Optional[str] = None, + contact: Optional["ApiContactInformation"] = None, + license: Optional["ApiLicenseInformation"] = None, source_api_id: Optional[str] = None, display_name: Optional[str] = None, service_url: Optional[str] = None, @@ -1060,7 +1541,76 @@ def __init__( soap_api_type: Optional[Union[str, "SoapApiType"]] = None, **kwargs ): - 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, 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) + """ + :keyword description: Description of the API. May include HTML formatting tags. + :paramtype description: str + :keyword authentication_settings: Collection of authentication settings included into this API. + :paramtype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :keyword subscription_key_parameter_names: Protocols over which API is made available. + :paramtype subscription_key_parameter_names: + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", + "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 + :keyword api_version: Indicates the version identifier of the API if the API is versioned. + :paramtype api_version: str + :keyword is_current: Indicates if API revision is current api revision. + :paramtype is_current: bool + :keyword api_revision_description: Description of the API Revision. + :paramtype api_revision_description: str + :keyword api_version_description: Description of the API Version. + :paramtype api_version_description: str + :keyword api_version_set_id: A resource identifier for the related ApiVersionSet. + :paramtype api_version_set_id: str + :keyword subscription_required: Specifies whether an API or Product subscription is required + for accessing the API. + :paramtype subscription_required: bool + :keyword terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format + of a URL. + :paramtype terms_of_service_url: str + :keyword contact: Contact information for the API. + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :keyword license: License information for the API. + :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + :keyword source_api_id: API identifier of the source API. + :paramtype source_api_id: str + :keyword display_name: API name. Must be 1 to 300 characters long. + :paramtype display_name: str + :keyword service_url: Absolute URL of the backend service implementing this API. Cannot be more + than 2000 characters long. + :paramtype service_url: str + :keyword path: 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. + :paramtype path: str + :keyword protocols: Describes on which protocols the operations in this API can be invoked. + :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + :keyword api_version_set: Version set details. + :paramtype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :keyword value: Content value when Importing an API. + :paramtype value: str + :keyword format: Format of the Content in which the API is getting imported. 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 ~azure.mgmt.apimanagement.models.ContentFormat + :keyword wsdl_selector: Criteria to limit import of WSDL to a subset of the document. + :paramtype wsdl_selector: + ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector + :keyword soap_api_type: Type of API to create. + + + * ``http`` creates a REST API + * ``soap`` creates a SOAP pass-through API + * ``websocket`` creates websocket API + * ``graphql`` creates GraphQL API. Possible values include: "http", "soap", "websocket", + "graphql". + :paramtype soap_api_type: str or ~azure.mgmt.apimanagement.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) self.value = value self.format = format self.wsdl_selector = wsdl_selector @@ -1070,10 +1620,10 @@ def __init__( class ApiCreateOrUpdatePropertiesWsdlSelector(msrest.serialization.Model): """Criteria to limit import of WSDL to a subset of the document. - :param wsdl_service_name: Name of service to import from WSDL. - :type wsdl_service_name: str - :param wsdl_endpoint_name: Name of endpoint(port) to import from WSDL. - :type wsdl_endpoint_name: str + :ivar wsdl_service_name: Name of service to import from WSDL. + :vartype wsdl_service_name: str + :ivar wsdl_endpoint_name: Name of endpoint(port) to import from WSDL. + :vartype wsdl_endpoint_name: str """ _attribute_map = { @@ -1088,6 +1638,12 @@ def __init__( 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) self.wsdl_service_name = wsdl_service_name self.wsdl_endpoint_name = wsdl_endpoint_name @@ -1096,14 +1652,14 @@ def __init__( class ApiExportResult(msrest.serialization.Model): """API Export result. - :param id: ResourceId of the API which was exported. - :type id: str - :param export_result_format: Format in which the Api Details are exported to the Storage Blob + :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". - :type export_result_format: str or ~azure.mgmt.apimanagement.models.ExportResultFormat - :param value: The object defining the schema of the exported Api Detail. - :type value: ~azure.mgmt.apimanagement.models.ApiExportResultValue + :vartype export_result_format: str or ~azure.mgmt.apimanagement.models.ExportResultFormat + :ivar value: The object defining the schema of the exported API Detail. + :vartype value: ~azure.mgmt.apimanagement.models.ApiExportResultValue """ _attribute_map = { @@ -1120,6 +1676,16 @@ def __init__( value: Optional["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 ~azure.mgmt.apimanagement.models.ExportResultFormat + :keyword value: The object defining the schema of the exported API Detail. + :paramtype value: ~azure.mgmt.apimanagement.models.ApiExportResultValue + """ super(ApiExportResult, self).__init__(**kwargs) self.id = id self.export_result_format = export_result_format @@ -1127,11 +1693,11 @@ def __init__( class ApiExportResultValue(msrest.serialization.Model): - """The object defining the schema of the exported Api Detail. + """The object defining the schema of the exported API Detail. - :param link: Link to the Storage Blob containing the result of the export operation. The Blob + :ivar link: Link to the Storage Blob containing the result of the export operation. The Blob Uri is only valid for 5 minutes. - :type link: str + :vartype link: str """ _attribute_map = { @@ -1144,16 +1710,53 @@ def __init__( 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) self.link = link +class ApiLicenseInformation(msrest.serialization.Model): + """API license information. + + :ivar name: The license name used for the API. + :vartype name: str + :ivar url: A URL to the license used for the API. MUST be in the format of a URL. + :vartype url: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'url': {'key': 'url', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + url: Optional[str] = None, + **kwargs + ): + """ + :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) + self.name = name + self.url = url + + class ApiManagementServiceApplyNetworkConfigurationParameters(msrest.serialization.Model): """Parameter supplied to the Apply Network configuration operation. - :param location: Location of the Api Management service to update for a multi-region service. + :ivar location: Location of the Api Management service to update for a multi-region service. For a service deployed in a single region, this parameter is not required. - :type location: str + :vartype location: str """ _attribute_map = { @@ -1166,6 +1769,11 @@ def __init__( 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) self.location = location @@ -1175,47 +1783,79 @@ class ApiManagementServiceBackupRestoreParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param storage_account: Required. Azure Cloud Storage account (used to place/retrieve the - backup) name. - :type storage_account: str - :param access_key: Required. Azure Cloud Storage account (used to place/retrieve the backup) - access key. - :type access_key: str - :param container_name: Required. Azure Cloud Storage blob container name used to place/retrieve - the backup. - :type container_name: str - :param backup_name: Required. The name of the backup file to create. - :type backup_name: str + :ivar storage_account: Required. The name of the Azure storage account (used to place/retrieve + the backup). + :vartype storage_account: str + :ivar container_name: Required. The name of the blob container (used to place/retrieve the + backup). + :vartype container_name: str + :ivar backup_name: Required. The name of the backup file to create/retrieve. + :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 ~azure.mgmt.apimanagement.models.AccessType + :ivar access_key: Storage account access key. Required only if ``accessType`` is set to + ``AccessKey``. + :vartype access_key: str + :ivar client_id: The Client ID of user assigned managed identity. Required only if + ``accessType`` is set to ``UserAssignedManagedIdentity``. + :vartype client_id: str """ _validation = { 'storage_account': {'required': True}, - 'access_key': {'required': True}, 'container_name': {'required': True}, 'backup_name': {'required': True}, } _attribute_map = { 'storage_account': {'key': 'storageAccount', 'type': 'str'}, - 'access_key': {'key': 'accessKey', 'type': 'str'}, 'container_name': {'key': 'containerName', 'type': 'str'}, 'backup_name': {'key': 'backupName', 'type': 'str'}, + 'access_type': {'key': 'accessType', 'type': 'str'}, + 'access_key': {'key': 'accessKey', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, } def __init__( self, *, storage_account: str, - access_key: str, container_name: str, backup_name: str, + access_type: Optional[Union[str, "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). + :paramtype storage_account: str + :keyword container_name: Required. The name of the blob container (used to place/retrieve the + backup). + :paramtype container_name: str + :keyword backup_name: Required. The name of the backup file to create/retrieve. + :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 ~azure.mgmt.apimanagement.models.AccessType + :keyword access_key: Storage account access key. Required only if ``accessType`` is set to + ``AccessKey``. + :paramtype access_key: str + :keyword client_id: The Client ID of user assigned managed identity. Required only if + ``accessType`` is set to ``UserAssignedManagedIdentity``. + :paramtype client_id: str + """ super(ApiManagementServiceBackupRestoreParameters, self).__init__(**kwargs) self.storage_account = storage_account - self.access_key = access_key self.container_name = container_name self.backup_name = backup_name + self.access_type = access_type + self.access_key = access_key + self.client_id = client_id class ApiManagementServiceBaseProperties(msrest.serialization.Model): @@ -1223,8 +1863,8 @@ class ApiManagementServiceBaseProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param notification_sender_email: Email address from which the notification will be sent. - :type notification_sender_email: str + :ivar notification_sender_email: Email address from which the notification will be sent. + :vartype notification_sender_email: str :ivar provisioning_state: The current provisioning state of the API Management service which can be one of the following: Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. @@ -1247,8 +1887,8 @@ class ApiManagementServiceBaseProperties(msrest.serialization.Model): :vartype scm_url: str :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. :vartype developer_portal_url: str - :param hostname_configurations: Custom hostname configuration of the API Management service. - :type hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] + :ivar hostname_configurations: Custom hostname configuration of the API Management service. + :vartype hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. :vartype public_ip_addresses: list[str] @@ -1256,13 +1896,22 @@ class ApiManagementServiceBaseProperties(msrest.serialization.Model): service in Primary region which is deployed in an Internal Virtual Network. Available only for Basic, Standard, Premium and Isolated SKU. :vartype private_ip_addresses: list[str] - :param virtual_network_configuration: Virtual network configuration of the API Management + :ivar public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with + Virtual Network deployed service in the region. Supported only for Developer and Premium SKU + being deployed in Virtual Network. + :vartype public_ip_address_id: str + :ivar public_network_access: Whether or not public endpoint access is allowed for this API + Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If + 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. + Possible values include: "Enabled", "Disabled". + :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess + :ivar virtual_network_configuration: Virtual network configuration of the API Management service. - :type virtual_network_configuration: + :vartype virtual_network_configuration: ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :param additional_locations: Additional datacenter locations of the API Management service. - :type additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :param custom_properties: Custom properties of the API Management service.
Setting + :ivar additional_locations: Additional datacenter locations of the API Management service. + :vartype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :ivar custom_properties: Custom properties of the API Management service.
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to @@ -1289,30 +1938,36 @@ class ApiManagementServiceBaseProperties(msrest.serialization.Model): ``false``. The default value is ``true`` for them. Note: next ciphers can't be disabled since they are required by Azure CloudService internal components: TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384. - :type custom_properties: dict[str, str] - :param certificates: List of Certificates that need to be installed in the API Management + :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. - :type certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :param enable_client_certificate: Property only meant to be used for Consumption SKU Service. + :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. - :type enable_client_certificate: bool - :param disable_gateway: Property only valid for an Api Management service deployed in multiple + :vartype enable_client_certificate: bool + :ivar disable_gateway: Property only valid for an Api Management service deployed in multiple locations. This can be used to disable the gateway in master region. - :type disable_gateway: bool - :param virtual_network_type: The type of VPN in which API Management service needs to be + :vartype disable_gateway: bool + :ivar virtual_network_type: The type of VPN in which API Management service needs to be configured in. None (Default Value) means the API Management service is not part of any Virtual Network, External means the API Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", "External", "Internal". Default value: "None". - :type virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :param api_version_constraint: Control Plane Apis version constraint for the API Management + :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. - :type api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :param restore: Undelete Api Management Service if it was previously soft-deleted. If this flag + :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. - :type restore: bool + :vartype restore: bool + :ivar private_endpoint_connections: List of Private Endpoint Connections of this service. + :vartype private_endpoint_connections: + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :ivar platform_version: Compute Platform Version running the service in this location. Possible + values include: "undetermined", "stv1", "stv2", "mtv1". + :vartype platform_version: str or ~azure.mgmt.apimanagement.models.PlatformVersion """ _validation = { @@ -1328,6 +1983,7 @@ class ApiManagementServiceBaseProperties(msrest.serialization.Model): 'developer_portal_url': {'readonly': True}, 'public_ip_addresses': {'readonly': True}, 'private_ip_addresses': {'readonly': True}, + 'platform_version': {'readonly': True}, } _attribute_map = { @@ -1344,6 +2000,8 @@ class ApiManagementServiceBaseProperties(msrest.serialization.Model): '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}'}, @@ -1353,6 +2011,8 @@ class ApiManagementServiceBaseProperties(msrest.serialization.Model): '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__( @@ -1360,6 +2020,8 @@ def __init__( *, notification_sender_email: Optional[str] = None, hostname_configurations: Optional[List["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, custom_properties: Optional[Dict[str, str]] = None, @@ -1369,8 +2031,85 @@ def __init__( virtual_network_type: Optional[Union[str, "VirtualNetworkType"]] = "None", api_version_constraint: Optional["ApiVersionConstraint"] = None, restore: Optional[bool] = False, - **kwargs - ): + private_endpoint_connections: Optional[List["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[~azure.mgmt.apimanagement.models.HostnameConfiguration] + :keyword public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with + Virtual Network deployed service in the region. Supported only for Developer and Premium SKU + being deployed in Virtual Network. + :paramtype public_ip_address_id: str + :keyword public_network_access: Whether or not public endpoint access is allowed for this API + Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If + 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. + Possible values include: "Enabled", "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: + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration + :keyword additional_locations: Additional datacenter locations of the API Management service. + :paramtype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :keyword custom_properties: Custom properties of the API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the + cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to + disable just TLS 1.1.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to + disable TLS 1.0 on an API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used + to disable just TLS 1.1 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used + to disable TLS 1.0 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable + HTTP2 protocol on an API Management service.
Not specifying any of these properties on + PATCH operation will reset omitted properties' values to their defaults. For all the settings + except Http2 the default value is ``True`` if the service was created on or before April 1st + 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can + disable any of next ciphers by using settings + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, + TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, + TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, + TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. + For example, + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ + ``false``. The default value is ``true`` for them. Note: next ciphers can't be disabled since + they are required by Azure CloudService internal components: + TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384. + :paramtype custom_properties: dict[str, str] + :keyword certificates: List of Certificates that need to be installed in the API Management + service. Max supported certificates that can be installed is 10. + :paramtype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] + :keyword enable_client_certificate: Property only meant to be used for Consumption SKU Service. + This enforces a client certificate to be presented on each request to the gateway. This also + enables the ability to authenticate the certificate in the policy on the gateway. + :paramtype enable_client_certificate: bool + :keyword disable_gateway: Property only valid for an Api Management service deployed in + multiple locations. This can be used to disable the gateway in master region. + :paramtype disable_gateway: bool + :keyword virtual_network_type: The type of VPN in which API Management service needs to be + configured in. None (Default Value) means the API Management service is not part of any Virtual + Network, External means the API Management deployment is set up inside a Virtual Network having + an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside + a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", + "External", "Internal". Default value: "None". + :paramtype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType + :keyword api_version_constraint: Control Plane Apis version constraint for the API Management + service. + :paramtype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint + :keyword restore: Undelete Api Management Service if it was previously soft-deleted. If this + flag is specified and set to True all other properties will be ignored. + :paramtype restore: bool + :keyword private_endpoint_connections: List of Private Endpoint Connections of this service. + :paramtype private_endpoint_connections: + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + """ super(ApiManagementServiceBaseProperties, self).__init__(**kwargs) self.notification_sender_email = notification_sender_email self.provisioning_state = None @@ -1385,6 +2124,8 @@ def __init__( self.hostname_configurations = hostname_configurations self.public_ip_addresses = None self.private_ip_addresses = None + self.public_ip_address_id = public_ip_address_id + self.public_network_access = public_network_access self.virtual_network_configuration = virtual_network_configuration self.additional_locations = additional_locations self.custom_properties = custom_properties @@ -1394,6 +2135,8 @@ def __init__( self.virtual_network_type = virtual_network_type self.api_version_constraint = api_version_constraint self.restore = restore + self.private_endpoint_connections = private_endpoint_connections + self.platform_version = None class ApiManagementServiceCheckNameAvailabilityParameters(msrest.serialization.Model): @@ -1401,8 +2144,8 @@ class ApiManagementServiceCheckNameAvailabilityParameters(msrest.serialization.M All required parameters must be populated in order to send to Azure. - :param name: Required. The name to check for availability. - :type name: str + :ivar name: Required. The name to check for availability. + :vartype name: str """ _validation = { @@ -1419,6 +2162,10 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The name to check for availability. + :paramtype name: str + """ super(ApiManagementServiceCheckNameAvailabilityParameters, self).__init__(**kwargs) self.name = name @@ -1444,6 +2191,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApiManagementServiceGetDomainOwnershipIdentifierResult, self).__init__(**kwargs) self.domain_ownership_identifier = None @@ -1451,8 +2200,8 @@ def __init__( class ApiManagementServiceGetSsoTokenResult(msrest.serialization.Model): """The response of the GetSsoToken operation. - :param redirect_uri: Redirect URL to the Publisher Portal containing the SSO token. - :type redirect_uri: str + :ivar redirect_uri: Redirect URL to the Publisher Portal containing the SSO token. + :vartype redirect_uri: str """ _attribute_map = { @@ -1465,6 +2214,10 @@ def __init__( 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) self.redirect_uri = redirect_uri @@ -1476,21 +2229,21 @@ class ApiManagementServiceIdentity(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. The type of identity used for the resource. The type 'SystemAssigned, + :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". - :type type: str or ~azure.mgmt.apimanagement.models.ApimIdentityType + :vartype type: str or ~azure.mgmt.apimanagement.models.ApimIdentityType :ivar principal_id: The principal id of the identity. :vartype principal_id: str :ivar tenant_id: The client tenant id of the identity. :vartype tenant_id: str - :param user_assigned_identities: The list of user identities associated with the resource. The + :ivar user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :type user_assigned_identities: dict[str, + :vartype user_assigned_identities: dict[str, ~azure.mgmt.apimanagement.models.UserIdentityProperties] """ @@ -1514,6 +2267,20 @@ def __init__( user_assigned_identities: Optional[Dict[str, "UserIdentityProperties"]] = None, **kwargs ): + """ + :keyword 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". + :paramtype type: str or ~azure.mgmt.apimanagement.models.ApimIdentityType + :keyword user_assigned_identities: The list of user identities associated with the resource. + The user identity + dictionary key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ + providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.apimanagement.models.UserIdentityProperties] + """ super(ApiManagementServiceIdentity, self).__init__(**kwargs) self.type = type self.principal_id = None @@ -1526,11 +2293,11 @@ class ApiManagementServiceListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. Result of the List API Management services operation. - :type value: list[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Required. Result of the List API Management services operation. + :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. - :type next_link: str + :vartype next_link: str """ _validation = { @@ -1549,6 +2316,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. Result of the List API Management services operation. + :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) self.value = value self.next_link = next_link @@ -1567,11 +2341,11 @@ class ApiManagementServiceNameAvailabilityResult(msrest.serialization.Model): If reason == AlreadyExists, explain that :code:`` is already in use, and direct them to select a different name. :vartype message: str - :param 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", + :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". - :type reason: str or ~azure.mgmt.apimanagement.models.NameAvailabilityReason + :vartype reason: str or ~azure.mgmt.apimanagement.models.NameAvailabilityReason """ _validation = { @@ -1591,6 +2365,13 @@ def __init__( reason: Optional[Union[str, "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 ~azure.mgmt.apimanagement.models.NameAvailabilityReason + """ super(ApiManagementServiceNameAvailabilityResult, self).__init__(**kwargs) self.name_available = None self.message = None @@ -1604,8 +2385,8 @@ class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): All required parameters must be populated in order to send to Azure. - :param notification_sender_email: Email address from which the notification will be sent. - :type notification_sender_email: str + :ivar notification_sender_email: Email address from which the notification will be sent. + :vartype notification_sender_email: str :ivar provisioning_state: The current provisioning state of the API Management service which can be one of the following: Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. @@ -1628,8 +2409,8 @@ class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): :vartype scm_url: str :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. :vartype developer_portal_url: str - :param hostname_configurations: Custom hostname configuration of the API Management service. - :type hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] + :ivar hostname_configurations: Custom hostname configuration of the API Management service. + :vartype hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. :vartype public_ip_addresses: list[str] @@ -1637,13 +2418,22 @@ class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): service in Primary region which is deployed in an Internal Virtual Network. Available only for Basic, Standard, Premium and Isolated SKU. :vartype private_ip_addresses: list[str] - :param virtual_network_configuration: Virtual network configuration of the API Management + :ivar public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with + Virtual Network deployed service in the region. Supported only for Developer and Premium SKU + being deployed in Virtual Network. + :vartype public_ip_address_id: str + :ivar public_network_access: Whether or not public endpoint access is allowed for this API + Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If + 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. + Possible values include: "Enabled", "Disabled". + :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess + :ivar virtual_network_configuration: Virtual network configuration of the API Management service. - :type virtual_network_configuration: + :vartype virtual_network_configuration: ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :param additional_locations: Additional datacenter locations of the API Management service. - :type additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :param custom_properties: Custom properties of the API Management service.
Setting + :ivar additional_locations: Additional datacenter locations of the API Management service. + :vartype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :ivar custom_properties: Custom properties of the API Management service.
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to @@ -1670,34 +2460,40 @@ class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): ``false``. The default value is ``true`` for them. Note: next ciphers can't be disabled since they are required by Azure CloudService internal components: TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384. - :type custom_properties: dict[str, str] - :param certificates: List of Certificates that need to be installed in the API Management + :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. - :type certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :param enable_client_certificate: Property only meant to be used for Consumption SKU Service. + :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. - :type enable_client_certificate: bool - :param disable_gateway: Property only valid for an Api Management service deployed in multiple + :vartype enable_client_certificate: bool + :ivar disable_gateway: Property only valid for an Api Management service deployed in multiple locations. This can be used to disable the gateway in master region. - :type disable_gateway: bool - :param virtual_network_type: The type of VPN in which API Management service needs to be + :vartype disable_gateway: bool + :ivar virtual_network_type: The type of VPN in which API Management service needs to be configured in. None (Default Value) means the API Management service is not part of any Virtual Network, External means the API Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", "External", "Internal". Default value: "None". - :type virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :param api_version_constraint: Control Plane Apis version constraint for the API Management + :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. - :type api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :param restore: Undelete Api Management Service if it was previously soft-deleted. If this flag + :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. - :type restore: bool - :param publisher_email: Required. Publisher email. - :type publisher_email: str - :param publisher_name: Required. Publisher name. - :type publisher_name: str + :vartype restore: bool + :ivar private_endpoint_connections: List of Private Endpoint Connections of this service. + :vartype private_endpoint_connections: + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :ivar platform_version: Compute Platform Version running the service in this location. Possible + values include: "undetermined", "stv1", "stv2", "mtv1". + :vartype platform_version: str or ~azure.mgmt.apimanagement.models.PlatformVersion + :ivar publisher_email: Required. Publisher email. + :vartype publisher_email: str + :ivar publisher_name: Required. Publisher name. + :vartype publisher_name: str """ _validation = { @@ -1713,6 +2509,7 @@ class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): '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}, } @@ -1731,6 +2528,8 @@ class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): '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}'}, @@ -1740,6 +2539,8 @@ class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): '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'}, } @@ -1751,6 +2552,8 @@ def __init__( publisher_name: str, notification_sender_email: Optional[str] = None, hostname_configurations: Optional[List["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, custom_properties: Optional[Dict[str, str]] = None, @@ -1760,9 +2563,90 @@ def __init__( virtual_network_type: Optional[Union[str, "VirtualNetworkType"]] = "None", api_version_constraint: Optional["ApiVersionConstraint"] = None, restore: Optional[bool] = False, - **kwargs - ): - super(ApiManagementServiceProperties, self).__init__(notification_sender_email=notification_sender_email, hostname_configurations=hostname_configurations, 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, **kwargs) + private_endpoint_connections: Optional[List["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[~azure.mgmt.apimanagement.models.HostnameConfiguration] + :keyword public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with + Virtual Network deployed service in the region. Supported only for Developer and Premium SKU + being deployed in Virtual Network. + :paramtype public_ip_address_id: str + :keyword public_network_access: Whether or not public endpoint access is allowed for this API + Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If + 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. + Possible values include: "Enabled", "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: + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration + :keyword additional_locations: Additional datacenter locations of the API Management service. + :paramtype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :keyword custom_properties: Custom properties of the API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the + cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to + disable just TLS 1.1.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to + disable TLS 1.0 on an API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used + to disable just TLS 1.1 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used + to disable TLS 1.0 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable + HTTP2 protocol on an API Management service.
Not specifying any of these properties on + PATCH operation will reset omitted properties' values to their defaults. For all the settings + except Http2 the default value is ``True`` if the service was created on or before April 1st + 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can + disable any of next ciphers by using settings + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, + TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, + TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, + TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. + For example, + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ + ``false``. The default value is ``true`` for them. Note: next ciphers can't be disabled since + they are required by Azure CloudService internal components: + TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384. + :paramtype custom_properties: dict[str, str] + :keyword certificates: List of Certificates that need to be installed in the API Management + service. Max supported certificates that can be installed is 10. + :paramtype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] + :keyword enable_client_certificate: Property only meant to be used for Consumption SKU Service. + This enforces a client certificate to be presented on each request to the gateway. This also + enables the ability to authenticate the certificate in the policy on the gateway. + :paramtype enable_client_certificate: bool + :keyword disable_gateway: Property only valid for an Api Management service deployed in + multiple locations. This can be used to disable the gateway in master region. + :paramtype disable_gateway: bool + :keyword virtual_network_type: The type of VPN in which API Management service needs to be + configured in. None (Default Value) means the API Management service is not part of any Virtual + Network, External means the API Management deployment is set up inside a Virtual Network having + an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside + a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", + "External", "Internal". Default value: "None". + :paramtype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType + :keyword api_version_constraint: Control Plane Apis version constraint for the API Management + service. + :paramtype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint + :keyword restore: Undelete Api Management Service if it was previously soft-deleted. If this + flag is specified and set to True all other properties will be ignored. + :paramtype restore: bool + :keyword private_endpoint_connections: List of Private Endpoint Connections of this service. + :paramtype private_endpoint_connections: + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :keyword publisher_email: Required. Publisher email. + :paramtype publisher_email: str + :keyword publisher_name: Required. Publisher name. + :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) self.publisher_email = publisher_email self.publisher_name = publisher_name @@ -1778,8 +2662,8 @@ class ApimResource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type for API Management resource is set to Microsoft.ApiManagement. :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1801,6 +2685,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(ApimResource, self).__init__(**kwargs) self.id = None self.name = None @@ -1821,20 +2709,22 @@ class ApiManagementServiceResource(ApimResource): :vartype name: str :ivar type: Resource type for API Management resource is set to Microsoft.ApiManagement. :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Required. SKU properties of the API Management service. - :type sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties - :param identity: Managed service identity of the Api Management service. - :type identity: ~azure.mgmt.apimanagement.models.ApiManagementServiceIdentity - :param location: Required. Resource location. - :type location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar sku: Required. SKU properties of the API Management service. + :vartype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties + :ivar identity: Managed service identity of the Api Management service. + :vartype identity: ~azure.mgmt.apimanagement.models.ApiManagementServiceIdentity + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar location: Required. Resource location. + :vartype location: str :ivar etag: ETag of the resource. :vartype etag: str - :param zones: A list of availability zones denoting where the resource needs to come from. - :type zones: list[str] - :param notification_sender_email: Email address from which the notification will be sent. - :type notification_sender_email: str + :ivar zones: A list of availability zones denoting where the resource needs to come from. + :vartype zones: list[str] + :ivar notification_sender_email: Email address from which the notification will be sent. + :vartype notification_sender_email: str :ivar provisioning_state: The current provisioning state of the API Management service which can be one of the following: Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. @@ -1857,8 +2747,8 @@ class ApiManagementServiceResource(ApimResource): :vartype scm_url: str :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. :vartype developer_portal_url: str - :param hostname_configurations: Custom hostname configuration of the API Management service. - :type hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] + :ivar hostname_configurations: Custom hostname configuration of the API Management service. + :vartype hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. :vartype public_ip_addresses: list[str] @@ -1866,13 +2756,22 @@ class ApiManagementServiceResource(ApimResource): service in Primary region which is deployed in an Internal Virtual Network. Available only for Basic, Standard, Premium and Isolated SKU. :vartype private_ip_addresses: list[str] - :param virtual_network_configuration: Virtual network configuration of the API Management + :ivar public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with + Virtual Network deployed service in the region. Supported only for Developer and Premium SKU + being deployed in Virtual Network. + :vartype public_ip_address_id: str + :ivar public_network_access: Whether or not public endpoint access is allowed for this API + Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If + 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. + Possible values include: "Enabled", "Disabled". + :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess + :ivar virtual_network_configuration: Virtual network configuration of the API Management service. - :type virtual_network_configuration: + :vartype virtual_network_configuration: ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :param additional_locations: Additional datacenter locations of the API Management service. - :type additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :param custom_properties: Custom properties of the API Management service.
Setting + :ivar additional_locations: Additional datacenter locations of the API Management service. + :vartype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :ivar custom_properties: Custom properties of the API Management service.
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to @@ -1899,34 +2798,40 @@ class ApiManagementServiceResource(ApimResource): ``false``. The default value is ``true`` for them. Note: next ciphers can't be disabled since they are required by Azure CloudService internal components: TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384. - :type custom_properties: dict[str, str] - :param certificates: List of Certificates that need to be installed in the API Management + :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. - :type certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :param enable_client_certificate: Property only meant to be used for Consumption SKU Service. + :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. - :type enable_client_certificate: bool - :param disable_gateway: Property only valid for an Api Management service deployed in multiple + :vartype enable_client_certificate: bool + :ivar disable_gateway: Property only valid for an Api Management service deployed in multiple locations. This can be used to disable the gateway in master region. - :type disable_gateway: bool - :param virtual_network_type: The type of VPN in which API Management service needs to be + :vartype disable_gateway: bool + :ivar virtual_network_type: The type of VPN in which API Management service needs to be configured in. None (Default Value) means the API Management service is not part of any Virtual Network, External means the API Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", "External", "Internal". Default value: "None". - :type virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :param api_version_constraint: Control Plane Apis version constraint for the API Management + :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. - :type api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :param restore: Undelete Api Management Service if it was previously soft-deleted. If this flag + :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. - :type restore: bool - :param publisher_email: Required. Publisher email. - :type publisher_email: str - :param publisher_name: Required. Publisher name. - :type publisher_name: str + :vartype restore: bool + :ivar private_endpoint_connections: List of Private Endpoint Connections of this service. + :vartype private_endpoint_connections: + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :ivar platform_version: Compute Platform Version running the service in this location. Possible + values include: "undetermined", "stv1", "stv2", "mtv1". + :vartype platform_version: str or ~azure.mgmt.apimanagement.models.PlatformVersion + :ivar publisher_email: Required. Publisher email. + :vartype publisher_email: str + :ivar publisher_name: Required. Publisher name. + :vartype publisher_name: str """ _validation = { @@ -1934,6 +2839,7 @@ class ApiManagementServiceResource(ApimResource): '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}, @@ -1948,6 +2854,7 @@ class ApiManagementServiceResource(ApimResource): '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}, } @@ -1959,6 +2866,7 @@ class ApiManagementServiceResource(ApimResource): '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]'}, @@ -1975,6 +2883,8 @@ class ApiManagementServiceResource(ApimResource): '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}'}, @@ -1984,6 +2894,8 @@ class ApiManagementServiceResource(ApimResource): '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'}, } @@ -2000,6 +2912,8 @@ def __init__( zones: Optional[List[str]] = None, notification_sender_email: Optional[str] = None, hostname_configurations: Optional[List["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, custom_properties: Optional[Dict[str, str]] = None, @@ -2009,11 +2923,103 @@ def __init__( virtual_network_type: Optional[Union[str, "VirtualNetworkType"]] = "None", api_version_constraint: Optional["ApiVersionConstraint"] = None, restore: Optional[bool] = False, - **kwargs - ): + private_endpoint_connections: Optional[List["RemotePrivateEndpointConnectionWrapper"]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: Required. SKU properties of the API Management service. + :paramtype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties + :keyword identity: Managed service identity of the Api Management service. + :paramtype identity: ~azure.mgmt.apimanagement.models.ApiManagementServiceIdentity + :keyword location: Required. Resource location. + :paramtype location: str + :keyword zones: A list of availability zones denoting where the resource needs to come from. + :paramtype zones: list[str] + :keyword notification_sender_email: Email address from which the notification will be sent. + :paramtype notification_sender_email: str + :keyword hostname_configurations: Custom hostname configuration of the API Management service. + :paramtype hostname_configurations: + list[~azure.mgmt.apimanagement.models.HostnameConfiguration] + :keyword public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with + Virtual Network deployed service in the region. Supported only for Developer and Premium SKU + being deployed in Virtual Network. + :paramtype public_ip_address_id: str + :keyword public_network_access: Whether or not public endpoint access is allowed for this API + Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If + 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. + Possible values include: "Enabled", "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: + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration + :keyword additional_locations: Additional datacenter locations of the API Management service. + :paramtype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :keyword custom_properties: Custom properties of the API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the + cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to + disable just TLS 1.1.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to + disable TLS 1.0 on an API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used + to disable just TLS 1.1 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used + to disable TLS 1.0 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable + HTTP2 protocol on an API Management service.
Not specifying any of these properties on + PATCH operation will reset omitted properties' values to their defaults. For all the settings + except Http2 the default value is ``True`` if the service was created on or before April 1st + 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can + disable any of next ciphers by using settings + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, + TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, + TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, + TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. + For example, + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ + ``false``. The default value is ``true`` for them. Note: next ciphers can't be disabled since + they are required by Azure CloudService internal components: + TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384. + :paramtype custom_properties: dict[str, str] + :keyword certificates: List of Certificates that need to be installed in the API Management + service. Max supported certificates that can be installed is 10. + :paramtype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] + :keyword enable_client_certificate: Property only meant to be used for Consumption SKU Service. + This enforces a client certificate to be presented on each request to the gateway. This also + enables the ability to authenticate the certificate in the policy on the gateway. + :paramtype enable_client_certificate: bool + :keyword disable_gateway: Property only valid for an Api Management service deployed in + multiple locations. This can be used to disable the gateway in master region. + :paramtype disable_gateway: bool + :keyword virtual_network_type: The type of VPN in which API Management service needs to be + configured in. None (Default Value) means the API Management service is not part of any Virtual + Network, External means the API Management deployment is set up inside a Virtual Network having + an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside + a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", + "External", "Internal". Default value: "None". + :paramtype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType + :keyword api_version_constraint: Control Plane Apis version constraint for the API Management + service. + :paramtype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint + :keyword restore: Undelete Api Management Service if it was previously soft-deleted. If this + flag is specified and set to True all other properties will be ignored. + :paramtype restore: bool + :keyword private_endpoint_connections: List of Private Endpoint Connections of this service. + :paramtype private_endpoint_connections: + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :keyword publisher_email: Required. Publisher email. + :paramtype publisher_email: str + :keyword publisher_name: Required. Publisher name. + :paramtype publisher_name: str + """ super(ApiManagementServiceResource, self).__init__(tags=tags, **kwargs) self.sku = sku self.identity = identity + self.system_data = None self.location = location self.etag = None self.zones = zones @@ -2030,6 +3036,8 @@ def __init__( self.hostname_configurations = hostname_configurations self.public_ip_addresses = None self.private_ip_addresses = None + self.public_ip_address_id = public_ip_address_id + self.public_network_access = public_network_access self.virtual_network_configuration = virtual_network_configuration self.additional_locations = additional_locations self.custom_properties = custom_properties @@ -2039,6 +3047,8 @@ def __init__( self.virtual_network_type = virtual_network_type self.api_version_constraint = api_version_constraint self.restore = restore + self.private_endpoint_connections = private_endpoint_connections + self.platform_version = None self.publisher_email = publisher_email self.publisher_name = publisher_name @@ -2048,12 +3058,12 @@ class ApiManagementServiceSkuProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the Sku. Possible values include: "Developer", "Standard", + :ivar name: Required. Name of the Sku. Possible values include: "Developer", "Standard", "Premium", "Basic", "Consumption", "Isolated". - :type name: str or ~azure.mgmt.apimanagement.models.SkuType - :param capacity: Required. Capacity of the SKU (number of deployed units of the SKU). For + :vartype name: str or ~azure.mgmt.apimanagement.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. - :type capacity: int + :vartype capacity: int """ _validation = { @@ -2073,6 +3083,14 @@ def __init__( capacity: int, **kwargs ): + """ + :keyword name: Required. Name of the Sku. Possible values include: "Developer", "Standard", + "Premium", "Basic", "Consumption", "Isolated". + :paramtype name: str or ~azure.mgmt.apimanagement.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. + :paramtype capacity: int + """ super(ApiManagementServiceSkuProperties, self).__init__(**kwargs) self.name = name self.capacity = capacity @@ -2089,16 +3107,18 @@ class ApiManagementServiceUpdateParameters(ApimResource): :vartype name: str :ivar type: Resource type for API Management resource is set to Microsoft.ApiManagement. :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: SKU properties of the API Management service. - :type sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties - :param identity: Managed service identity of the Api Management service. - :type identity: ~azure.mgmt.apimanagement.models.ApiManagementServiceIdentity + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar sku: SKU properties of the API Management service. + :vartype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties + :ivar identity: Managed service identity of the Api Management service. + :vartype identity: ~azure.mgmt.apimanagement.models.ApiManagementServiceIdentity :ivar etag: ETag of the resource. :vartype etag: str - :param notification_sender_email: Email address from which the notification will be sent. - :type notification_sender_email: str + :ivar zones: A list of availability zones denoting where the resource needs to come from. + :vartype zones: list[str] + :ivar notification_sender_email: Email address from which the notification will be sent. + :vartype notification_sender_email: str :ivar provisioning_state: The current provisioning state of the API Management service which can be one of the following: Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. @@ -2121,8 +3141,8 @@ class ApiManagementServiceUpdateParameters(ApimResource): :vartype scm_url: str :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. :vartype developer_portal_url: str - :param hostname_configurations: Custom hostname configuration of the API Management service. - :type hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] + :ivar hostname_configurations: Custom hostname configuration of the API Management service. + :vartype hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. :vartype public_ip_addresses: list[str] @@ -2130,13 +3150,22 @@ class ApiManagementServiceUpdateParameters(ApimResource): service in Primary region which is deployed in an Internal Virtual Network. Available only for Basic, Standard, Premium and Isolated SKU. :vartype private_ip_addresses: list[str] - :param virtual_network_configuration: Virtual network configuration of the API Management + :ivar public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with + Virtual Network deployed service in the region. Supported only for Developer and Premium SKU + being deployed in Virtual Network. + :vartype public_ip_address_id: str + :ivar public_network_access: Whether or not public endpoint access is allowed for this API + Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If + 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. + Possible values include: "Enabled", "Disabled". + :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess + :ivar virtual_network_configuration: Virtual network configuration of the API Management service. - :type virtual_network_configuration: + :vartype virtual_network_configuration: ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :param additional_locations: Additional datacenter locations of the API Management service. - :type additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :param custom_properties: Custom properties of the API Management service.
Setting + :ivar additional_locations: Additional datacenter locations of the API Management service. + :vartype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :ivar custom_properties: Custom properties of the API Management service.
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to @@ -2163,34 +3192,40 @@ class ApiManagementServiceUpdateParameters(ApimResource): ``false``. The default value is ``true`` for them. Note: next ciphers can't be disabled since they are required by Azure CloudService internal components: TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384. - :type custom_properties: dict[str, str] - :param certificates: List of Certificates that need to be installed in the API Management + :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. - :type certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :param enable_client_certificate: Property only meant to be used for Consumption SKU Service. + :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. - :type enable_client_certificate: bool - :param disable_gateway: Property only valid for an Api Management service deployed in multiple + :vartype enable_client_certificate: bool + :ivar disable_gateway: Property only valid for an Api Management service deployed in multiple locations. This can be used to disable the gateway in master region. - :type disable_gateway: bool - :param virtual_network_type: The type of VPN in which API Management service needs to be + :vartype disable_gateway: bool + :ivar virtual_network_type: The type of VPN in which API Management service needs to be configured in. None (Default Value) means the API Management service is not part of any Virtual Network, External means the API Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", "External", "Internal". Default value: "None". - :type virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :param api_version_constraint: Control Plane Apis version constraint for the API Management + :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. - :type api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :param restore: Undelete Api Management Service if it was previously soft-deleted. If this flag + :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. - :type restore: bool - :param publisher_email: Publisher email. - :type publisher_email: str - :param publisher_name: Publisher name. - :type publisher_name: str + :vartype restore: bool + :ivar private_endpoint_connections: List of Private Endpoint Connections of this service. + :vartype private_endpoint_connections: + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :ivar platform_version: Compute Platform Version running the service in this location. Possible + values include: "undetermined", "stv1", "stv2", "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. + :vartype publisher_name: str """ _validation = { @@ -2210,6 +3245,7 @@ class ApiManagementServiceUpdateParameters(ApimResource): '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}, } @@ -2222,6 +3258,7 @@ class ApiManagementServiceUpdateParameters(ApimResource): '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'}, @@ -2235,6 +3272,8 @@ class ApiManagementServiceUpdateParameters(ApimResource): '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}'}, @@ -2244,6 +3283,8 @@ class ApiManagementServiceUpdateParameters(ApimResource): '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'}, } @@ -2254,8 +3295,11 @@ def __init__( tags: Optional[Dict[str, str]] = None, sku: Optional["ApiManagementServiceSkuProperties"] = None, identity: Optional["ApiManagementServiceIdentity"] = None, + zones: Optional[List[str]] = None, notification_sender_email: Optional[str] = None, hostname_configurations: Optional[List["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, custom_properties: Optional[Dict[str, str]] = None, @@ -2265,14 +3309,104 @@ def __init__( 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, publisher_email: Optional[str] = None, publisher_name: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: SKU properties of the API Management service. + :paramtype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties + :keyword identity: Managed service identity of the Api Management service. + :paramtype identity: ~azure.mgmt.apimanagement.models.ApiManagementServiceIdentity + :keyword zones: A list of availability zones denoting where the resource needs to come from. + :paramtype zones: list[str] + :keyword notification_sender_email: Email address from which the notification will be sent. + :paramtype notification_sender_email: str + :keyword hostname_configurations: Custom hostname configuration of the API Management service. + :paramtype hostname_configurations: + list[~azure.mgmt.apimanagement.models.HostnameConfiguration] + :keyword public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with + Virtual Network deployed service in the region. Supported only for Developer and Premium SKU + being deployed in Virtual Network. + :paramtype public_ip_address_id: str + :keyword public_network_access: Whether or not public endpoint access is allowed for this API + Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If + 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. + Possible values include: "Enabled", "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: + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration + :keyword additional_locations: Additional datacenter locations of the API Management service. + :paramtype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :keyword custom_properties: Custom properties of the API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the + cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to + disable just TLS 1.1.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to + disable TLS 1.0 on an API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used + to disable just TLS 1.1 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used + to disable TLS 1.0 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable + HTTP2 protocol on an API Management service.
Not specifying any of these properties on + PATCH operation will reset omitted properties' values to their defaults. For all the settings + except Http2 the default value is ``True`` if the service was created on or before April 1st + 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can + disable any of next ciphers by using settings + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, + TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, + TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, + TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. + For example, + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ + ``false``. The default value is ``true`` for them. Note: next ciphers can't be disabled since + they are required by Azure CloudService internal components: + TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384. + :paramtype custom_properties: dict[str, str] + :keyword certificates: List of Certificates that need to be installed in the API Management + service. Max supported certificates that can be installed is 10. + :paramtype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] + :keyword enable_client_certificate: Property only meant to be used for Consumption SKU Service. + This enforces a client certificate to be presented on each request to the gateway. This also + enables the ability to authenticate the certificate in the policy on the gateway. + :paramtype enable_client_certificate: bool + :keyword disable_gateway: Property only valid for an Api Management service deployed in + multiple locations. This can be used to disable the gateway in master region. + :paramtype disable_gateway: bool + :keyword virtual_network_type: The type of VPN in which API Management service needs to be + configured in. None (Default Value) means the API Management service is not part of any Virtual + Network, External means the API Management deployment is set up inside a Virtual Network having + an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside + a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", + "External", "Internal". Default value: "None". + :paramtype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType + :keyword api_version_constraint: Control Plane Apis version constraint for the API Management + service. + :paramtype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint + :keyword restore: Undelete Api Management Service if it was previously soft-deleted. If this + flag is specified and set to True all other properties will be ignored. + :paramtype restore: bool + :keyword private_endpoint_connections: List of Private Endpoint Connections of this service. + :paramtype private_endpoint_connections: + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :keyword publisher_email: Publisher email. + :paramtype publisher_email: str + :keyword publisher_name: Publisher name. + :paramtype publisher_name: str + """ super(ApiManagementServiceUpdateParameters, self).__init__(tags=tags, **kwargs) self.sku = sku self.identity = identity self.etag = None + self.zones = zones self.notification_sender_email = notification_sender_email self.provisioning_state = None self.target_provisioning_state = None @@ -2286,6 +3420,8 @@ def __init__( self.hostname_configurations = hostname_configurations self.public_ip_addresses = None self.private_ip_addresses = None + self.public_ip_address_id = public_ip_address_id + self.public_network_access = public_network_access self.virtual_network_configuration = virtual_network_configuration self.additional_locations = additional_locations self.custom_properties = custom_properties @@ -2295,6 +3431,8 @@ def __init__( self.virtual_network_type = virtual_network_type self.api_version_constraint = api_version_constraint self.restore = restore + self.private_endpoint_connections = private_endpoint_connections + self.platform_version = None self.publisher_email = publisher_email self.publisher_name = publisher_name @@ -2304,8 +3442,8 @@ class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): Variables are only populated by the server, and will be ignored when sending a request. - :param notification_sender_email: Email address from which the notification will be sent. - :type notification_sender_email: str + :ivar notification_sender_email: Email address from which the notification will be sent. + :vartype notification_sender_email: str :ivar provisioning_state: The current provisioning state of the API Management service which can be one of the following: Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. @@ -2328,8 +3466,8 @@ class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): :vartype scm_url: str :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. :vartype developer_portal_url: str - :param hostname_configurations: Custom hostname configuration of the API Management service. - :type hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] + :ivar hostname_configurations: Custom hostname configuration of the API Management service. + :vartype hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. :vartype public_ip_addresses: list[str] @@ -2337,13 +3475,22 @@ class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): service in Primary region which is deployed in an Internal Virtual Network. Available only for Basic, Standard, Premium and Isolated SKU. :vartype private_ip_addresses: list[str] - :param virtual_network_configuration: Virtual network configuration of the API Management + :ivar public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with + Virtual Network deployed service in the region. Supported only for Developer and Premium SKU + being deployed in Virtual Network. + :vartype public_ip_address_id: str + :ivar public_network_access: Whether or not public endpoint access is allowed for this API + Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If + 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. + Possible values include: "Enabled", "Disabled". + :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess + :ivar virtual_network_configuration: Virtual network configuration of the API Management service. - :type virtual_network_configuration: + :vartype virtual_network_configuration: ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :param additional_locations: Additional datacenter locations of the API Management service. - :type additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :param custom_properties: Custom properties of the API Management service.
Setting + :ivar additional_locations: Additional datacenter locations of the API Management service. + :vartype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :ivar custom_properties: Custom properties of the API Management service.
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to @@ -2370,34 +3517,40 @@ class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): ``false``. The default value is ``true`` for them. Note: next ciphers can't be disabled since they are required by Azure CloudService internal components: TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384. - :type custom_properties: dict[str, str] - :param certificates: List of Certificates that need to be installed in the API Management + :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. - :type certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :param enable_client_certificate: Property only meant to be used for Consumption SKU Service. + :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. - :type enable_client_certificate: bool - :param disable_gateway: Property only valid for an Api Management service deployed in multiple + :vartype enable_client_certificate: bool + :ivar disable_gateway: Property only valid for an Api Management service deployed in multiple locations. This can be used to disable the gateway in master region. - :type disable_gateway: bool - :param virtual_network_type: The type of VPN in which API Management service needs to be + :vartype disable_gateway: bool + :ivar virtual_network_type: The type of VPN in which API Management service needs to be configured in. None (Default Value) means the API Management service is not part of any Virtual Network, External means the API Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", "External", "Internal". Default value: "None". - :type virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :param api_version_constraint: Control Plane Apis version constraint for the API Management + :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. - :type api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :param restore: Undelete Api Management Service if it was previously soft-deleted. If this flag + :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. - :type restore: bool - :param publisher_email: Publisher email. - :type publisher_email: str - :param publisher_name: Publisher name. - :type publisher_name: str + :vartype restore: bool + :ivar private_endpoint_connections: List of Private Endpoint Connections of this service. + :vartype private_endpoint_connections: + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :ivar platform_version: Compute Platform Version running the service in this location. Possible + values include: "undetermined", "stv1", "stv2", "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. + :vartype publisher_name: str """ _validation = { @@ -2413,6 +3566,7 @@ class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): '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}, } @@ -2431,6 +3585,8 @@ class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): '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}'}, @@ -2440,6 +3596,8 @@ class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): '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'}, } @@ -2449,6 +3607,8 @@ def __init__( *, notification_sender_email: Optional[str] = None, hostname_configurations: Optional[List["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, custom_properties: Optional[Dict[str, str]] = None, @@ -2458,11 +3618,92 @@ def __init__( 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, publisher_email: Optional[str] = None, publisher_name: Optional[str] = None, **kwargs ): - super(ApiManagementServiceUpdateProperties, self).__init__(notification_sender_email=notification_sender_email, hostname_configurations=hostname_configurations, 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, **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[~azure.mgmt.apimanagement.models.HostnameConfiguration] + :keyword public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with + Virtual Network deployed service in the region. Supported only for Developer and Premium SKU + being deployed in Virtual Network. + :paramtype public_ip_address_id: str + :keyword public_network_access: Whether or not public endpoint access is allowed for this API + Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If + 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. + Possible values include: "Enabled", "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: + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration + :keyword additional_locations: Additional datacenter locations of the API Management service. + :paramtype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :keyword custom_properties: Custom properties of the API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the + cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to + disable just TLS 1.1.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to + disable TLS 1.0 on an API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used + to disable just TLS 1.1 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used + to disable TLS 1.0 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable + HTTP2 protocol on an API Management service.
Not specifying any of these properties on + PATCH operation will reset omitted properties' values to their defaults. For all the settings + except Http2 the default value is ``True`` if the service was created on or before April 1st + 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can + disable any of next ciphers by using settings + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, + TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, + TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, + TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. + For example, + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ + ``false``. The default value is ``true`` for them. Note: next ciphers can't be disabled since + they are required by Azure CloudService internal components: + TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384. + :paramtype custom_properties: dict[str, str] + :keyword certificates: List of Certificates that need to be installed in the API Management + service. Max supported certificates that can be installed is 10. + :paramtype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] + :keyword enable_client_certificate: Property only meant to be used for Consumption SKU Service. + This enforces a client certificate to be presented on each request to the gateway. This also + enables the ability to authenticate the certificate in the policy on the gateway. + :paramtype enable_client_certificate: bool + :keyword disable_gateway: Property only valid for an Api Management service deployed in + multiple locations. This can be used to disable the gateway in master region. + :paramtype disable_gateway: bool + :keyword virtual_network_type: The type of VPN in which API Management service needs to be + configured in. None (Default Value) means the API Management service is not part of any Virtual + Network, External means the API Management deployment is set up inside a Virtual Network having + an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside + a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", + "External", "Internal". Default value: "None". + :paramtype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType + :keyword api_version_constraint: Control Plane Apis version constraint for the API Management + service. + :paramtype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint + :keyword restore: Undelete Api Management Service if it was previously soft-deleted. If this + flag is specified and set to True all other properties will be ignored. + :paramtype restore: bool + :keyword private_endpoint_connections: List of Private Endpoint Connections of this service. + :paramtype private_endpoint_connections: + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :keyword 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) self.publisher_email = publisher_email self.publisher_name = publisher_name @@ -2540,6 +3781,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApiManagementSku, self).__init__(**kwargs) self.resource_type = None self.name = None @@ -2581,6 +3824,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApiManagementSkuCapabilities, self).__init__(**kwargs) self.name = None self.value = None @@ -2620,6 +3865,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApiManagementSkuCapacity, self).__init__(**kwargs) self.minimum = None self.maximum = None @@ -2656,6 +3903,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApiManagementSkuCosts, self).__init__(**kwargs) self.meter_id = None self.quantity = None @@ -2691,6 +3940,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApiManagementSkuLocationInfo, self).__init__(**kwargs) self.location = None self.zones = None @@ -2722,6 +3973,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApiManagementSkuRestrictionInfo, self).__init__(**kwargs) self.locations = None self.zones = None @@ -2763,6 +4016,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApiManagementSkuRestrictions, self).__init__(**kwargs) self.type = None self.values = None @@ -2777,8 +4032,8 @@ class ApiManagementSkusResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. The list of skus available for the subscription. - :type value: list[~azure.mgmt.apimanagement.models.ApiManagementSku] + :ivar value: Required. The list of skus available for the subscription. + :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 @@ -2800,6 +4055,10 @@ def __init__( value: List["ApiManagementSku"], **kwargs ): + """ + :keyword value: Required. The list of skus available for the subscription. + :paramtype value: list[~azure.mgmt.apimanagement.models.ApiManagementSku] + """ super(ApiManagementSkusResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2831,6 +4090,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApiManagementSkuZoneDetails, self).__init__(**kwargs) self.name = None self.capabilities = None @@ -2843,8 +4104,8 @@ class ApiReleaseCollection(msrest.serialization.Model): :ivar value: Page values. :vartype value: list[~azure.mgmt.apimanagement.models.ApiReleaseContract] - :param count: Total record count number across all pages. - :type count: long + :ivar count: Total record count number across all pages. + :vartype count: long :ivar next_link: Next page link if any. :vartype next_link: str """ @@ -2866,6 +4127,10 @@ def __init__( count: Optional[int] = None, **kwargs ): + """ + :keyword count: Total record count number across all pages. + :paramtype count: long + """ super(ApiReleaseCollection, self).__init__(**kwargs) self.value = None self.count = count @@ -2877,21 +4142,23 @@ class ApiReleaseContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param api_id: Identifier of the API the release belongs to. - :type api_id: str + :ivar api_id: Identifier of the API the release belongs to. + :vartype api_id: str :ivar created_date_time: The time the API was released. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. :vartype created_date_time: ~datetime.datetime :ivar updated_date_time: The time the API release was updated. :vartype updated_date_time: ~datetime.datetime - :param notes: Release Notes. - :type notes: str + :ivar notes: Release Notes. + :vartype notes: str """ _validation = { @@ -2919,6 +4186,12 @@ def __init__( 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) self.api_id = api_id self.created_date_time = None @@ -2927,14 +4200,14 @@ def __init__( class ApiRevisionCollection(msrest.serialization.Model): - """Paged Api Revision list representation. + """Paged API Revision list representation. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Page values. :vartype value: list[~azure.mgmt.apimanagement.models.ApiRevisionContract] - :param count: Total record count number across all pages. - :type count: long + :ivar count: Total record count number across all pages. + :vartype count: long :ivar next_link: Next page link if any. :vartype next_link: str """ @@ -2956,6 +4229,10 @@ def __init__( count: Optional[int] = None, **kwargs ): + """ + :keyword count: Total record count number across all pages. + :paramtype count: long + """ super(ApiRevisionCollection, self).__init__(**kwargs) self.value = None self.count = count @@ -3013,6 +4290,8 @@ def __init__( self, **kwargs ): + """ + """ super(ApiRevisionContract, self).__init__(**kwargs) self.api_id = None self.api_revision = None @@ -3027,14 +4306,14 @@ def __init__( class ApiRevisionInfoContract(msrest.serialization.Model): """Object used to create an API Revision or Version based on an existing API Revision. - :param source_api_id: Resource identifier of API to be used to create the revision from. - :type source_api_id: str - :param api_version_name: Version identifier for the new API Version. - :type api_version_name: str - :param api_revision_description: Description of new API Revision. - :type api_revision_description: str - :param api_version_set: Version set details. - :type api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :ivar source_api_id: Resource identifier of API to be used to create the revision from. + :vartype source_api_id: str + :ivar api_version_name: Version identifier for the new API Version. + :vartype api_version_name: str + :ivar api_revision_description: Description of new API Revision. + :vartype api_revision_description: str + :ivar api_version_set: Version set details. + :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ _validation = { @@ -3058,6 +4337,16 @@ def __init__( api_version_set: Optional["ApiVersionSetContractDetails"] = None, **kwargs ): + """ + :keyword source_api_id: Resource identifier of API to be used to create the revision from. + :paramtype source_api_id: str + :keyword api_version_name: Version identifier for the new API Version. + :paramtype api_version_name: str + :keyword api_revision_description: Description of new API Revision. + :paramtype api_revision_description: str + :keyword api_version_set: Version set details. + :paramtype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + """ super(ApiRevisionInfoContract, self).__init__(**kwargs) self.source_api_id = source_api_id self.api_version_name = api_version_name @@ -3070,45 +4359,53 @@ class ApiTagResourceContractProperties(ApiEntityBaseContract): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the API. May include HTML formatting tags. - :type description: str - :param authentication_settings: Collection of authentication settings included into this API. - :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made available. - :type subscription_key_parameter_names: + :ivar description: Description of the API. May include HTML formatting tags. + :vartype description: str + :ivar authentication_settings: Collection of authentication settings included into this API. + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :ivar subscription_key_parameter_names: Protocols over which API is made available. + :vartype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: "http", "soap". - :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is provided, default + :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "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. - :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API is versioned. - :type api_version: str - :param is_current: Indicates if API revision is current api revision. - :type is_current: bool + :vartype api_revision: str + :ivar api_version: Indicates the version identifier of the API if the API is versioned. + :vartype api_version: str + :ivar is_current: Indicates if API revision is current api revision. + :vartype is_current: bool :ivar is_online: Indicates if API revision is accessible via the gateway. :vartype is_online: bool - :param api_revision_description: Description of the Api Revision. - :type api_revision_description: str - :param api_version_description: Description of the Api Version. - :type api_version_description: str - :param api_version_set_id: A resource identifier for the related ApiVersionSet. - :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product subscription is required for + :ivar api_revision_description: Description of the API Revision. + :vartype api_revision_description: str + :ivar api_version_description: Description of the API Version. + :vartype api_version_description: str + :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. + :vartype api_version_set_id: str + :ivar subscription_required: Specifies whether an API or Product subscription is required for accessing the API. - :type subscription_required: bool - :param id: API identifier in the form /apis/{apiId}. - :type id: str - :param name: API name. - :type name: str - :param service_url: Absolute URL of the backend service implementing this API. - :type service_url: str - :param 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. - :type path: str - :param protocols: Describes on which protocols the operations in this API can be invoked. - :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + :vartype subscription_required: bool + :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of + a URL. + :vartype terms_of_service_url: str + :ivar contact: Contact information for the API. + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :ivar license: License information for the API. + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + :ivar id: API identifier in the form /apis/{apiId}. + :vartype id: str + :ivar name: API name. + :vartype name: str + :ivar service_url: Absolute URL of the backend service implementing this API. + :vartype service_url: str + :ivar path: Relative URL uniquely identifying this API and all of its resource paths within the + API Management service instance. It is appended to the API endpoint base URL specified during + the service instance creation to form a public URL for this API. + :vartype path: str + :ivar protocols: Describes on which protocols the operations in this API can be invoked. + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] """ _validation = { @@ -3135,6 +4432,9 @@ class ApiTagResourceContractProperties(ApiEntityBaseContract): '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'}, @@ -3156,6 +4456,9 @@ def __init__( api_version_description: Optional[str] = None, api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, + terms_of_service_url: Optional[str] = None, + contact: Optional["ApiContactInformation"] = None, + license: Optional["ApiLicenseInformation"] = None, id: Optional[str] = None, name: Optional[str] = None, service_url: Optional[str] = None, @@ -3163,7 +4466,55 @@ def __init__( protocols: Optional[List[Union[str, "Protocol"]]] = None, **kwargs ): - 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, **kwargs) + """ + :keyword description: Description of the API. May include HTML formatting tags. + :paramtype description: str + :keyword authentication_settings: Collection of authentication settings included into this API. + :paramtype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :keyword subscription_key_parameter_names: Protocols over which API is made available. + :paramtype subscription_key_parameter_names: + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", + "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 + :keyword api_version: Indicates the version identifier of the API if the API is versioned. + :paramtype api_version: str + :keyword is_current: Indicates if API revision is current api revision. + :paramtype is_current: bool + :keyword api_revision_description: Description of the API Revision. + :paramtype api_revision_description: str + :keyword api_version_description: Description of the API Version. + :paramtype api_version_description: str + :keyword api_version_set_id: A resource identifier for the related ApiVersionSet. + :paramtype api_version_set_id: str + :keyword subscription_required: Specifies whether an API or Product subscription is required + for accessing the API. + :paramtype subscription_required: bool + :keyword terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format + of a URL. + :paramtype terms_of_service_url: str + :keyword contact: Contact information for the API. + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :keyword license: License information for the API. + :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + :keyword id: API identifier in the form /apis/{apiId}. + :paramtype id: str + :keyword name: API name. + :paramtype name: str + :keyword service_url: Absolute URL of the backend service implementing this API. + :paramtype service_url: str + :keyword path: Relative URL uniquely identifying this API and all of its resource paths within + the API Management service instance. It is appended to the API endpoint base URL specified + during the service instance creation to form a public URL for this API. + :paramtype path: str + :keyword protocols: Describes on which protocols the operations in this API can be invoked. + :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + """ + super(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) self.id = id self.name = name self.service_url = service_url @@ -3176,43 +4527,51 @@ class ApiUpdateContract(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the API. May include HTML formatting tags. - :type description: str - :param authentication_settings: Collection of authentication settings included into this API. - :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made available. - :type subscription_key_parameter_names: + :ivar description: Description of the API. May include HTML formatting tags. + :vartype description: str + :ivar authentication_settings: Collection of authentication settings included into this API. + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :ivar subscription_key_parameter_names: Protocols over which API is made available. + :vartype subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: "http", "soap". - :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is provided, default + :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "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. - :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API is versioned. - :type api_version: str - :param is_current: Indicates if API revision is current api revision. - :type is_current: bool + :vartype api_revision: str + :ivar api_version: Indicates the version identifier of the API if the API is versioned. + :vartype api_version: str + :ivar is_current: Indicates if API revision is current api revision. + :vartype is_current: bool :ivar is_online: Indicates if API revision is accessible via the gateway. :vartype is_online: bool - :param api_revision_description: Description of the Api Revision. - :type api_revision_description: str - :param api_version_description: Description of the Api Version. - :type api_version_description: str - :param api_version_set_id: A resource identifier for the related ApiVersionSet. - :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product subscription is required for + :ivar api_revision_description: Description of the API Revision. + :vartype api_revision_description: str + :ivar api_version_description: Description of the API Version. + :vartype api_version_description: str + :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. + :vartype api_version_set_id: str + :ivar subscription_required: Specifies whether an API or Product subscription is required for accessing the API. - :type subscription_required: bool - :param display_name: API name. - :type display_name: str - :param service_url: Absolute URL of the backend service implementing this API. - :type service_url: str - :param 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. - :type path: str - :param protocols: Describes on which protocols the operations in this API can be invoked. - :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + :vartype subscription_required: bool + :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of + a URL. + :vartype terms_of_service_url: str + :ivar contact: Contact information for the API. + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :ivar license: License information for the API. + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + :ivar display_name: API name. + :vartype display_name: str + :ivar service_url: Absolute URL of the backend service implementing this API. + :vartype service_url: str + :ivar path: Relative URL uniquely identifying this API and all of its resource paths within the + API Management service instance. It is appended to the API endpoint base URL specified during + the service instance creation to form a public URL for this API. + :vartype path: str + :ivar protocols: Describes on which protocols the operations in this API can be invoked. + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] """ _validation = { @@ -3239,6 +4598,9 @@ class ApiUpdateContract(msrest.serialization.Model): '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'}, @@ -3259,12 +4621,61 @@ def __init__( api_version_description: Optional[str] = None, api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, + terms_of_service_url: Optional[str] = None, + contact: Optional["ApiContactInformation"] = None, + license: Optional["ApiLicenseInformation"] = None, display_name: Optional[str] = None, service_url: Optional[str] = None, path: Optional[str] = None, protocols: Optional[List[Union[str, "Protocol"]]] = None, **kwargs ): + """ + :keyword description: Description of the API. May include HTML formatting tags. + :paramtype description: str + :keyword authentication_settings: Collection of authentication settings included into this API. + :paramtype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :keyword subscription_key_parameter_names: Protocols over which API is made available. + :paramtype subscription_key_parameter_names: + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", + "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 + :keyword api_version: Indicates the version identifier of the API if the API is versioned. + :paramtype api_version: str + :keyword is_current: Indicates if API revision is current api revision. + :paramtype is_current: bool + :keyword api_revision_description: Description of the API Revision. + :paramtype api_revision_description: str + :keyword api_version_description: Description of the API Version. + :paramtype api_version_description: str + :keyword api_version_set_id: A resource identifier for the related ApiVersionSet. + :paramtype api_version_set_id: str + :keyword subscription_required: Specifies whether an API or Product subscription is required + for accessing the API. + :paramtype subscription_required: bool + :keyword terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format + of a URL. + :paramtype terms_of_service_url: str + :keyword contact: Contact information for the API. + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :keyword license: License information for the API. + :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + :keyword display_name: API name. + :paramtype display_name: str + :keyword service_url: Absolute URL of the backend service implementing this API. + :paramtype service_url: str + :keyword path: Relative URL uniquely identifying this API and all of its resource paths within + the API Management service instance. It is appended to the API endpoint base URL specified + during the service instance creation to form a public URL for this API. + :paramtype path: str + :keyword protocols: Describes on which protocols the operations in this API can be invoked. + :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + """ super(ApiUpdateContract, self).__init__(**kwargs) self.description = description self.authentication_settings = authentication_settings @@ -3278,6 +4689,9 @@ def __init__( self.api_version_description = api_version_description self.api_version_set_id = api_version_set_id self.subscription_required = subscription_required + self.terms_of_service_url = terms_of_service_url + self.contact = contact + self.license = license self.display_name = display_name self.service_url = service_url self.path = path @@ -3287,9 +4701,9 @@ def __init__( class ApiVersionConstraint(msrest.serialization.Model): """Control Plane Apis version constraint for the API Management service. - :param min_api_version: Limit control plane API calls to API Management service with version + :ivar min_api_version: Limit control plane API calls to API Management service with version equal to or newer than this value. - :type min_api_version: str + :vartype min_api_version: str """ _attribute_map = { @@ -3302,19 +4716,24 @@ def __init__( 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) self.min_api_version = min_api_version class ApiVersionSetCollection(msrest.serialization.Model): - """Paged Api Version Set list representation. + """Paged API Version Set list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.ApiVersionSetContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.ApiVersionSetContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -3331,6 +4750,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.ApiVersionSetContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(ApiVersionSetCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -3338,29 +4765,31 @@ def __init__( class ApiVersionSetContract(Resource): - """Api Version Set Contract details. + """API Version Set Contract details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param description: Description of API Version Set. - :type description: str - :param version_query_name: Name of query parameter that indicates the API Version if + :ivar description: Description of API Version Set. + :vartype description: str + :ivar version_query_name: Name of query parameter that indicates the API Version if versioningScheme is set to ``query``. - :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates the API Version if + :vartype version_query_name: str + :ivar version_header_name: Name of HTTP header parameter that indicates the API Version if versioningScheme is set to ``header``. - :type version_header_name: str - :param display_name: Name of API Version Set. - :type display_name: str - :param versioning_scheme: An value that determines where the API Version identifier will be + :vartype version_header_name: str + :ivar display_name: Name of API Version Set. + :vartype display_name: str + :ivar versioning_scheme: An value that determines where the API Version identifier will be located in a HTTP request. Possible values include: "Segment", "Query", "Header". - :type versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme + :vartype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme """ _validation = { @@ -3393,6 +4822,21 @@ def __init__( versioning_scheme: Optional[Union[str, "VersioningScheme"]] = None, **kwargs ): + """ + :keyword description: Description of API Version Set. + :paramtype description: str + :keyword version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. + :paramtype version_query_name: str + :keyword version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. + :paramtype version_header_name: str + :keyword display_name: Name of API Version Set. + :paramtype display_name: str + :keyword versioning_scheme: An value that determines where the API Version identifier will be + located in a HTTP request. Possible values include: "Segment", "Query", "Header". + :paramtype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme + """ super(ApiVersionSetContract, self).__init__(**kwargs) self.description = description self.version_query_name = version_query_name @@ -3404,23 +4848,22 @@ def __init__( class ApiVersionSetContractDetails(msrest.serialization.Model): """An API Version Set contains the common configuration for a set of API Versions relating. - :param id: Identifier for existing API Version Set. Omit this value to create a new Version - Set. - :type id: str - :param name: The display Name of the API Version Set. - :type name: str - :param description: Description of API Version Set. - :type description: str - :param versioning_scheme: An value that determines where the API Version identifier will be + :ivar id: Identifier for existing API Version Set. Omit this value to create a new Version Set. + :vartype id: str + :ivar name: The display Name of the API Version Set. + :vartype name: str + :ivar description: Description of API Version Set. + :vartype description: str + :ivar versioning_scheme: An value that determines where the API Version identifier will be located in a HTTP request. Possible values include: "Segment", "Query", "Header". - :type versioning_scheme: str or + :vartype versioning_scheme: str or ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetailsVersioningScheme - :param version_query_name: Name of query parameter that indicates the API Version if + :ivar version_query_name: Name of query parameter that indicates the API Version if versioningScheme is set to ``query``. - :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates the API Version if + :vartype version_query_name: str + :ivar version_header_name: Name of HTTP header parameter that indicates the API Version if versioningScheme is set to ``header``. - :type version_header_name: str + :vartype version_header_name: str """ _attribute_map = { @@ -3443,6 +4886,25 @@ def __init__( version_header_name: Optional[str] = None, **kwargs ): + """ + :keyword id: Identifier for existing API Version Set. Omit this value to create a new Version + Set. + :paramtype id: str + :keyword name: The display Name of the API Version Set. + :paramtype name: str + :keyword description: Description of API Version Set. + :paramtype description: str + :keyword versioning_scheme: An value that determines where the API Version identifier will be + located in a HTTP request. Possible values include: "Segment", "Query", "Header". + :paramtype versioning_scheme: str or + ~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 + :keyword version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. + :paramtype version_header_name: str + """ super(ApiVersionSetContractDetails, self).__init__(**kwargs) self.id = id self.name = name @@ -3453,16 +4915,16 @@ def __init__( class ApiVersionSetEntityBase(msrest.serialization.Model): - """Api Version set base parameters. + """API Version set base parameters. - :param description: Description of API Version Set. - :type description: str - :param version_query_name: Name of query parameter that indicates the API Version if + :ivar description: Description of API Version Set. + :vartype description: str + :ivar version_query_name: Name of query parameter that indicates the API Version if versioningScheme is set to ``query``. - :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates the API Version if + :vartype version_query_name: str + :ivar version_header_name: Name of HTTP header parameter that indicates the API Version if versioningScheme is set to ``header``. - :type version_header_name: str + :vartype version_header_name: str """ _validation = { @@ -3484,6 +4946,16 @@ def __init__( version_header_name: Optional[str] = None, **kwargs ): + """ + :keyword description: Description of API Version Set. + :paramtype description: str + :keyword version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. + :paramtype version_query_name: str + :keyword version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. + :paramtype version_header_name: str + """ super(ApiVersionSetEntityBase, self).__init__(**kwargs) self.description = description self.version_query_name = version_query_name @@ -3495,19 +4967,19 @@ class ApiVersionSetContractProperties(ApiVersionSetEntityBase): All required parameters must be populated in order to send to Azure. - :param description: Description of API Version Set. - :type description: str - :param version_query_name: Name of query parameter that indicates the API Version if + :ivar description: Description of API Version Set. + :vartype description: str + :ivar version_query_name: Name of query parameter that indicates the API Version if versioningScheme is set to ``query``. - :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates the API Version if + :vartype version_query_name: str + :ivar version_header_name: Name of HTTP header parameter that indicates the API Version if versioningScheme is set to ``header``. - :type version_header_name: str - :param display_name: Required. Name of API Version Set. - :type display_name: str - :param versioning_scheme: Required. An value that determines where the API Version identifier + :vartype version_header_name: str + :ivar display_name: Required. Name of API Version Set. + :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". - :type versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme + :vartype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme """ _validation = { @@ -3535,27 +5007,42 @@ def __init__( version_header_name: Optional[str] = None, **kwargs ): + """ + :keyword description: Description of API Version Set. + :paramtype description: str + :keyword version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. + :paramtype version_query_name: str + :keyword version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. + :paramtype version_header_name: str + :keyword display_name: Required. Name of API Version Set. + :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 ~azure.mgmt.apimanagement.models.VersioningScheme + """ super(ApiVersionSetContractProperties, self).__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): - """Parameters to update or create an Api Version Set Contract. + """Parameters to update or create an API Version Set Contract. - :param description: Description of API Version Set. - :type description: str - :param version_query_name: Name of query parameter that indicates the API Version if + :ivar description: Description of API Version Set. + :vartype description: str + :ivar version_query_name: Name of query parameter that indicates the API Version if versioningScheme is set to ``query``. - :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates the API Version if + :vartype version_query_name: str + :ivar version_header_name: Name of HTTP header parameter that indicates the API Version if versioningScheme is set to ``header``. - :type version_header_name: str - :param display_name: Name of API Version Set. - :type display_name: str - :param versioning_scheme: An value that determines where the API Version identifier will be + :vartype version_header_name: str + :ivar display_name: Name of API Version Set. + :vartype display_name: str + :ivar versioning_scheme: An value that determines where the API Version identifier will be located in a HTTP request. Possible values include: "Segment", "Query", "Header". - :type versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme + :vartype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme """ _validation = { @@ -3582,6 +5069,21 @@ def __init__( versioning_scheme: Optional[Union[str, "VersioningScheme"]] = None, **kwargs ): + """ + :keyword description: Description of API Version Set. + :paramtype description: str + :keyword version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. + :paramtype version_query_name: str + :keyword version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. + :paramtype version_header_name: str + :keyword display_name: Name of API Version Set. + :paramtype display_name: str + :keyword versioning_scheme: An value that determines where the API Version identifier will be + located in a HTTP request. Possible values include: "Segment", "Query", "Header". + :paramtype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme + """ super(ApiVersionSetUpdateParameters, self).__init__(**kwargs) self.description = description self.version_query_name = version_query_name @@ -3593,19 +5095,19 @@ def __init__( class ApiVersionSetUpdateParametersProperties(ApiVersionSetEntityBase): """Properties used to create or update an API Version Set. - :param description: Description of API Version Set. - :type description: str - :param version_query_name: Name of query parameter that indicates the API Version if + :ivar description: Description of API Version Set. + :vartype description: str + :ivar version_query_name: Name of query parameter that indicates the API Version if versioningScheme is set to ``query``. - :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates the API Version if + :vartype version_query_name: str + :ivar version_header_name: Name of HTTP header parameter that indicates the API Version if versioningScheme is set to ``header``. - :type version_header_name: str - :param display_name: Name of API Version Set. - :type display_name: str - :param versioning_scheme: An value that determines where the API Version identifier will be + :vartype version_header_name: str + :ivar display_name: Name of API Version Set. + :vartype display_name: str + :ivar versioning_scheme: An value that determines where the API Version identifier will be located in a HTTP request. Possible values include: "Segment", "Query", "Header". - :type versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme + :vartype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme """ _validation = { @@ -3632,25 +5134,69 @@ def __init__( versioning_scheme: Optional[Union[str, "VersioningScheme"]] = None, **kwargs ): + """ + :keyword description: Description of API Version Set. + :paramtype description: str + :keyword version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. + :paramtype version_query_name: str + :keyword version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. + :paramtype version_header_name: str + :keyword display_name: Name of API Version Set. + :paramtype display_name: str + :keyword versioning_scheme: An value that determines where the API Version identifier will be + located in a HTTP request. Possible values include: "Segment", "Query", "Header". + :paramtype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme + """ super(ApiVersionSetUpdateParametersProperties, self).__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): + """A wrapper for an ARM resource id. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: + :vartype id: str + """ + + _validation = { + 'id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ArmIdWrapper, self).__init__(**kwargs) + self.id = None + + class AssociationContract(Resource): """Association entity details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param provisioning_state: Provisioning state. The only acceptable values to pass in are None + :ivar provisioning_state: Provisioning state. The only acceptable values to pass in are None and "created". The default value is None. - :type provisioning_state: str + :vartype provisioning_state: str """ _validation = { @@ -3672,6 +5218,11 @@ def __init__( 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. + :paramtype provisioning_state: str + """ super(AssociationContract, self).__init__(**kwargs) self.provisioning_state = provisioning_state @@ -3679,10 +5230,10 @@ def __init__( class AuthenticationSettingsContract(msrest.serialization.Model): """API Authentication Settings. - :param o_auth2: OAuth2 Authentication settings. - :type o_auth2: ~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract - :param openid: OpenID Connect Authentication Settings. - :type openid: ~azure.mgmt.apimanagement.models.OpenIdAuthenticationSettingsContract + :ivar o_auth2: OAuth2 Authentication settings. + :vartype o_auth2: ~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract + :ivar openid: OpenID Connect Authentication Settings. + :vartype openid: ~azure.mgmt.apimanagement.models.OpenIdAuthenticationSettingsContract """ _attribute_map = { @@ -3697,6 +5248,12 @@ def __init__( openid: Optional["OpenIdAuthenticationSettingsContract"] = None, **kwargs ): + """ + :keyword o_auth2: OAuth2 Authentication settings. + :paramtype o_auth2: ~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract + :keyword openid: OpenID Connect Authentication Settings. + :paramtype openid: ~azure.mgmt.apimanagement.models.OpenIdAuthenticationSettingsContract + """ super(AuthenticationSettingsContract, self).__init__(**kwargs) self.o_auth2 = o_auth2 self.openid = openid @@ -3705,12 +5262,12 @@ def __init__( class AuthorizationServerCollection(msrest.serialization.Model): """Paged OAuth2 Authorization Servers list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.AuthorizationServerContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.AuthorizationServerContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -3727,6 +5284,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.AuthorizationServerContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(AuthorizationServerCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -3738,65 +5303,69 @@ class AuthorizationServerContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param description: Description of the authorization server. Can contain HTML formatting tags. - :type description: str - :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + :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. - :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :param 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, + :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. - :type client_authentication_method: list[str or + :vartype client_authentication_method: list[str or ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :param token_body_parameters: Additional parameters required by the token endpoint of this + :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"}. - :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. - :type token_endpoint: str - :param support_state: If true, authorization server will include state parameter from the + :vartype token_body_parameters: + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :ivar token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. + :vartype token_endpoint: str + :ivar support_state: If true, authorization server will include state parameter from the authorization request to its response. Client may use state parameter to raise protocol security. - :type support_state: bool - :param default_scope: Access token scope that is going to be requested by default. Can be + :vartype support_state: bool + :ivar default_scope: Access token scope that is going to be requested by default. Can be overridden at the API level. Should be provided in the form of a string containing space-delimited values. - :type default_scope: str - :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to + :vartype default_scope: str + :ivar bearer_token_sending_methods: Specifies the mechanism by which access token is passed to the API. - :type bearer_token_sending_methods: list[str or + :vartype bearer_token_sending_methods: list[str or ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :param resource_owner_username: Can be optionally specified when resource owner password grant + :ivar resource_owner_username: Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. - :type resource_owner_username: str - :param resource_owner_password: Can be optionally specified when resource owner password grant + :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. - :type resource_owner_password: str - :param display_name: User-friendly authorization server name. - :type display_name: str - :param client_registration_endpoint: Optional reference to a page where client or app + :vartype resource_owner_password: str + :ivar display_name: User-friendly authorization server name. + :vartype display_name: str + :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. - :type client_registration_endpoint: str - :param authorization_endpoint: OAuth authorization endpoint. See + :vartype client_registration_endpoint: str + :ivar authorization_endpoint: OAuth authorization endpoint. See http://tools.ietf.org/html/rfc6749#section-3.2. - :type authorization_endpoint: str - :param grant_types: Form of an authorization grant, which the client uses to request the access + :vartype authorization_endpoint: str + :ivar grant_types: Form of an authorization grant, which the client uses to request the access token. - :type grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :param client_id: Client or app id registered with this authorization server. - :type client_id: str - :param client_secret: Client or app secret registered with this authorization server. This + :vartype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] + :ivar client_id: Client or app id registered with this authorization server. + :vartype client_id: str + :ivar client_secret: Client or app secret registered with this authorization server. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. - :type client_secret: str + :vartype client_secret: str """ _validation = { @@ -3849,6 +5418,65 @@ def __init__( client_secret: Optional[str] = None, **kwargs ): + """ + :keyword description: Description of the authorization server. Can contain HTML formatting + tags. + :paramtype description: str + :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + always present. POST is optional. + :paramtype authorization_methods: list[str or + ~azure.mgmt.apimanagement.models.AuthorizationMethod] + :keyword client_authentication_method: Method of authentication supported by the token endpoint + of this authorization server. Possible values are Basic and/or Body. When Body is specified, + client credentials and other parameters are passed within the request body in the + application/x-www-form-urlencoded format. + :paramtype client_authentication_method: list[str or + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] + :keyword token_body_parameters: Additional parameters required by the token endpoint of this + authorization server represented as an array of JSON objects with name and value string + properties, i.e. {"name" : "name value", "value": "a value"}. + :paramtype token_body_parameters: + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being + referenced. + :paramtype token_endpoint: str + :keyword support_state: If true, authorization server will include state parameter from the + authorization request to its response. Client may use state parameter to raise protocol + security. + :paramtype support_state: bool + :keyword default_scope: Access token scope that is going to be requested by default. Can be + overridden at the API level. Should be provided in the form of a string containing + space-delimited values. + :paramtype default_scope: str + :keyword bearer_token_sending_methods: Specifies the mechanism by which access token is passed + to the API. + :paramtype bearer_token_sending_methods: list[str or + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] + :keyword resource_owner_username: Can be optionally specified when resource owner password + grant type is supported by this authorization server. Default resource owner username. + :paramtype resource_owner_username: str + :keyword resource_owner_password: Can be optionally specified when resource owner password + grant type is supported by this authorization server. Default resource owner password. + :paramtype resource_owner_password: str + :keyword display_name: User-friendly authorization server name. + :paramtype display_name: str + :keyword client_registration_endpoint: Optional reference to a page where client or app + registration for this authorization server is performed. Contains absolute URL to entity being + referenced. + :paramtype client_registration_endpoint: str + :keyword authorization_endpoint: OAuth authorization endpoint. See + http://tools.ietf.org/html/rfc6749#section-3.2. + :paramtype authorization_endpoint: str + :keyword grant_types: Form of an authorization grant, which the client uses to request the + access token. + :paramtype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] + :keyword client_id: Client or app id registered with this authorization server. + :paramtype client_id: str + :keyword client_secret: Client or app secret registered with this authorization server. This + property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the + value. + :paramtype client_secret: str + """ super(AuthorizationServerContract, self).__init__(**kwargs) self.description = description self.authorization_methods = authorization_methods @@ -3871,41 +5499,43 @@ def __init__( class AuthorizationServerContractBaseProperties(msrest.serialization.Model): """External OAuth authorization server Update settings contract. - :param description: Description of the authorization server. Can contain HTML formatting tags. - :type description: str - :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + :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. - :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :param 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, + :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. - :type client_authentication_method: list[str or + :vartype client_authentication_method: list[str or ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :param token_body_parameters: Additional parameters required by the token endpoint of this + :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"}. - :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. - :type token_endpoint: str - :param support_state: If true, authorization server will include state parameter from the + :vartype token_body_parameters: + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :ivar token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. + :vartype token_endpoint: str + :ivar support_state: If true, authorization server will include state parameter from the authorization request to its response. Client may use state parameter to raise protocol security. - :type support_state: bool - :param default_scope: Access token scope that is going to be requested by default. Can be + :vartype support_state: bool + :ivar default_scope: Access token scope that is going to be requested by default. Can be overridden at the API level. Should be provided in the form of a string containing space-delimited values. - :type default_scope: str - :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to + :vartype default_scope: str + :ivar bearer_token_sending_methods: Specifies the mechanism by which access token is passed to the API. - :type bearer_token_sending_methods: list[str or + :vartype bearer_token_sending_methods: list[str or ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :param resource_owner_username: Can be optionally specified when resource owner password grant + :ivar resource_owner_username: Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. - :type resource_owner_username: str - :param resource_owner_password: Can be optionally specified when resource owner password grant + :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. - :type resource_owner_password: str + :vartype resource_owner_password: str """ _attribute_map = { @@ -3936,6 +5566,47 @@ def __init__( resource_owner_password: Optional[str] = None, **kwargs ): + """ + :keyword description: Description of the authorization server. Can contain HTML formatting + tags. + :paramtype description: str + :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + always present. POST is optional. + :paramtype authorization_methods: list[str or + ~azure.mgmt.apimanagement.models.AuthorizationMethod] + :keyword client_authentication_method: Method of authentication supported by the token endpoint + of this authorization server. Possible values are Basic and/or Body. When Body is specified, + client credentials and other parameters are passed within the request body in the + application/x-www-form-urlencoded format. + :paramtype client_authentication_method: list[str or + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] + :keyword token_body_parameters: Additional parameters required by the token endpoint of this + authorization server represented as an array of JSON objects with name and value string + properties, i.e. {"name" : "name value", "value": "a value"}. + :paramtype token_body_parameters: + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being + referenced. + :paramtype token_endpoint: str + :keyword support_state: If true, authorization server will include state parameter from the + authorization request to its response. Client may use state parameter to raise protocol + security. + :paramtype support_state: bool + :keyword default_scope: Access token scope that is going to be requested by default. Can be + overridden at the API level. Should be provided in the form of a string containing + space-delimited values. + :paramtype default_scope: str + :keyword bearer_token_sending_methods: Specifies the mechanism by which access token is passed + to the API. + :paramtype bearer_token_sending_methods: list[str or + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] + :keyword resource_owner_username: Can be optionally specified when resource owner password + grant type is supported by this authorization server. Default resource owner username. + :paramtype resource_owner_username: str + :keyword resource_owner_password: Can be optionally specified when resource owner password + grant type is supported by this authorization server. Default resource owner password. + :paramtype resource_owner_password: str + """ super(AuthorizationServerContractBaseProperties, self).__init__(**kwargs) self.description = description self.authorization_methods = authorization_methods @@ -3954,59 +5625,61 @@ class AuthorizationServerContractProperties(AuthorizationServerContractBasePrope All required parameters must be populated in order to send to Azure. - :param description: Description of the authorization server. Can contain HTML formatting tags. - :type description: str - :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + :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. - :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :param 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, + :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. - :type client_authentication_method: list[str or + :vartype client_authentication_method: list[str or ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :param token_body_parameters: Additional parameters required by the token endpoint of this + :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"}. - :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. - :type token_endpoint: str - :param support_state: If true, authorization server will include state parameter from the + :vartype token_body_parameters: + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :ivar token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. + :vartype token_endpoint: str + :ivar support_state: If true, authorization server will include state parameter from the authorization request to its response. Client may use state parameter to raise protocol security. - :type support_state: bool - :param default_scope: Access token scope that is going to be requested by default. Can be + :vartype support_state: bool + :ivar default_scope: Access token scope that is going to be requested by default. Can be overridden at the API level. Should be provided in the form of a string containing space-delimited values. - :type default_scope: str - :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to + :vartype default_scope: str + :ivar bearer_token_sending_methods: Specifies the mechanism by which access token is passed to the API. - :type bearer_token_sending_methods: list[str or + :vartype bearer_token_sending_methods: list[str or ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :param resource_owner_username: Can be optionally specified when resource owner password grant + :ivar resource_owner_username: Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. - :type resource_owner_username: str - :param resource_owner_password: Can be optionally specified when resource owner password grant + :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. - :type resource_owner_password: str - :param display_name: Required. User-friendly authorization server name. - :type display_name: str - :param client_registration_endpoint: Required. Optional reference to a page where client or app + :vartype resource_owner_password: str + :ivar display_name: Required. User-friendly authorization server name. + :vartype display_name: str + :ivar 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. - :type client_registration_endpoint: str - :param authorization_endpoint: Required. OAuth authorization endpoint. See + :vartype client_registration_endpoint: str + :ivar authorization_endpoint: Required. OAuth authorization endpoint. See http://tools.ietf.org/html/rfc6749#section-3.2. - :type authorization_endpoint: str - :param grant_types: Required. Form of an authorization grant, which the client uses to request + :vartype authorization_endpoint: str + :ivar grant_types: Required. Form of an authorization grant, which the client uses to request the access token. - :type grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :param client_id: Required. Client or app id registered with this authorization server. - :type client_id: str - :param client_secret: Client or app secret registered with this authorization server. This + :vartype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] + :ivar client_id: Required. Client or app id registered with this authorization server. + :vartype client_id: str + :ivar client_secret: Client or app secret registered with this authorization server. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. - :type client_secret: str + :vartype client_secret: str """ _validation = { @@ -4057,6 +5730,65 @@ def __init__( client_secret: Optional[str] = None, **kwargs ): + """ + :keyword description: Description of the authorization server. Can contain HTML formatting + tags. + :paramtype description: str + :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + always present. POST is optional. + :paramtype authorization_methods: list[str or + ~azure.mgmt.apimanagement.models.AuthorizationMethod] + :keyword client_authentication_method: Method of authentication supported by the token endpoint + of this authorization server. Possible values are Basic and/or Body. When Body is specified, + client credentials and other parameters are passed within the request body in the + application/x-www-form-urlencoded format. + :paramtype client_authentication_method: list[str or + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] + :keyword token_body_parameters: Additional parameters required by the token endpoint of this + authorization server represented as an array of JSON objects with name and value string + properties, i.e. {"name" : "name value", "value": "a value"}. + :paramtype token_body_parameters: + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being + referenced. + :paramtype token_endpoint: str + :keyword support_state: If true, authorization server will include state parameter from the + authorization request to its response. Client may use state parameter to raise protocol + security. + :paramtype support_state: bool + :keyword default_scope: Access token scope that is going to be requested by default. Can be + overridden at the API level. Should be provided in the form of a string containing + space-delimited values. + :paramtype default_scope: str + :keyword bearer_token_sending_methods: Specifies the mechanism by which access token is passed + to the API. + :paramtype bearer_token_sending_methods: list[str or + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] + :keyword resource_owner_username: Can be optionally specified when resource owner password + grant type is supported by this authorization server. Default resource owner username. + :paramtype resource_owner_username: str + :keyword resource_owner_password: Can be optionally specified when resource owner password + grant type is supported by this authorization server. Default resource owner password. + :paramtype resource_owner_password: str + :keyword display_name: Required. User-friendly authorization server name. + :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. + :paramtype client_registration_endpoint: str + :keyword authorization_endpoint: Required. OAuth authorization endpoint. See + http://tools.ietf.org/html/rfc6749#section-3.2. + :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 ~azure.mgmt.apimanagement.models.GrantType] + :keyword client_id: Required. Client or app id registered with this authorization server. + :paramtype client_id: str + :keyword client_secret: Client or app secret registered with this authorization server. This + property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the + value. + :paramtype client_secret: str + """ super(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) self.display_name = display_name self.client_registration_endpoint = client_registration_endpoint @@ -4069,14 +5801,14 @@ def __init__( class AuthorizationServerSecretsContract(msrest.serialization.Model): """OAuth Server Secrets Contract. - :param client_secret: oAuth Authorization Server Secrets. - :type client_secret: str - :param resource_owner_username: Can be optionally specified when resource owner password grant + :ivar client_secret: oAuth Authorization Server Secrets. + :vartype client_secret: str + :ivar resource_owner_username: Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. - :type resource_owner_username: str - :param resource_owner_password: Can be optionally specified when resource owner password grant + :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. - :type resource_owner_password: str + :vartype resource_owner_password: str """ _attribute_map = { @@ -4093,6 +5825,16 @@ def __init__( resource_owner_password: Optional[str] = None, **kwargs ): + """ + :keyword client_secret: oAuth Authorization Server Secrets. + :paramtype client_secret: str + :keyword resource_owner_username: Can be optionally specified when resource owner password + grant type is supported by this authorization server. Default resource owner username. + :paramtype resource_owner_username: str + :keyword resource_owner_password: Can be optionally specified when resource owner password + grant type is supported by this authorization server. Default resource owner password. + :paramtype resource_owner_password: str + """ super(AuthorizationServerSecretsContract, self).__init__(**kwargs) self.client_secret = client_secret self.resource_owner_username = resource_owner_username @@ -4104,65 +5846,69 @@ class AuthorizationServerUpdateContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param description: Description of the authorization server. Can contain HTML formatting tags. - :type description: str - :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + :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. - :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :param 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, + :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. - :type client_authentication_method: list[str or + :vartype client_authentication_method: list[str or ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :param token_body_parameters: Additional parameters required by the token endpoint of this + :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"}. - :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. - :type token_endpoint: str - :param support_state: If true, authorization server will include state parameter from the + :vartype token_body_parameters: + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :ivar token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. + :vartype token_endpoint: str + :ivar support_state: If true, authorization server will include state parameter from the authorization request to its response. Client may use state parameter to raise protocol security. - :type support_state: bool - :param default_scope: Access token scope that is going to be requested by default. Can be + :vartype support_state: bool + :ivar default_scope: Access token scope that is going to be requested by default. Can be overridden at the API level. Should be provided in the form of a string containing space-delimited values. - :type default_scope: str - :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to + :vartype default_scope: str + :ivar bearer_token_sending_methods: Specifies the mechanism by which access token is passed to the API. - :type bearer_token_sending_methods: list[str or + :vartype bearer_token_sending_methods: list[str or ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :param resource_owner_username: Can be optionally specified when resource owner password grant + :ivar resource_owner_username: Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. - :type resource_owner_username: str - :param resource_owner_password: Can be optionally specified when resource owner password grant + :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. - :type resource_owner_password: str - :param display_name: User-friendly authorization server name. - :type display_name: str - :param client_registration_endpoint: Optional reference to a page where client or app + :vartype resource_owner_password: str + :ivar display_name: User-friendly authorization server name. + :vartype display_name: str + :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. - :type client_registration_endpoint: str - :param authorization_endpoint: OAuth authorization endpoint. See + :vartype client_registration_endpoint: str + :ivar authorization_endpoint: OAuth authorization endpoint. See http://tools.ietf.org/html/rfc6749#section-3.2. - :type authorization_endpoint: str - :param grant_types: Form of an authorization grant, which the client uses to request the access + :vartype authorization_endpoint: str + :ivar grant_types: Form of an authorization grant, which the client uses to request the access token. - :type grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :param client_id: Client or app id registered with this authorization server. - :type client_id: str - :param client_secret: Client or app secret registered with this authorization server. This + :vartype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] + :ivar client_id: Client or app id registered with this authorization server. + :vartype client_id: str + :ivar client_secret: Client or app secret registered with this authorization server. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. - :type client_secret: str + :vartype client_secret: str """ _validation = { @@ -4215,6 +5961,65 @@ def __init__( client_secret: Optional[str] = None, **kwargs ): + """ + :keyword description: Description of the authorization server. Can contain HTML formatting + tags. + :paramtype description: str + :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + always present. POST is optional. + :paramtype authorization_methods: list[str or + ~azure.mgmt.apimanagement.models.AuthorizationMethod] + :keyword client_authentication_method: Method of authentication supported by the token endpoint + of this authorization server. Possible values are Basic and/or Body. When Body is specified, + client credentials and other parameters are passed within the request body in the + application/x-www-form-urlencoded format. + :paramtype client_authentication_method: list[str or + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] + :keyword token_body_parameters: Additional parameters required by the token endpoint of this + authorization server represented as an array of JSON objects with name and value string + properties, i.e. {"name" : "name value", "value": "a value"}. + :paramtype token_body_parameters: + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being + referenced. + :paramtype token_endpoint: str + :keyword support_state: If true, authorization server will include state parameter from the + authorization request to its response. Client may use state parameter to raise protocol + security. + :paramtype support_state: bool + :keyword default_scope: Access token scope that is going to be requested by default. Can be + overridden at the API level. Should be provided in the form of a string containing + space-delimited values. + :paramtype default_scope: str + :keyword bearer_token_sending_methods: Specifies the mechanism by which access token is passed + to the API. + :paramtype bearer_token_sending_methods: list[str or + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] + :keyword resource_owner_username: Can be optionally specified when resource owner password + grant type is supported by this authorization server. Default resource owner username. + :paramtype resource_owner_username: str + :keyword resource_owner_password: Can be optionally specified when resource owner password + grant type is supported by this authorization server. Default resource owner password. + :paramtype resource_owner_password: str + :keyword display_name: User-friendly authorization server name. + :paramtype display_name: str + :keyword client_registration_endpoint: Optional reference to a page where client or app + registration for this authorization server is performed. Contains absolute URL to entity being + referenced. + :paramtype client_registration_endpoint: str + :keyword authorization_endpoint: OAuth authorization endpoint. See + http://tools.ietf.org/html/rfc6749#section-3.2. + :paramtype authorization_endpoint: str + :keyword grant_types: Form of an authorization grant, which the client uses to request the + access token. + :paramtype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] + :keyword client_id: Client or app id registered with this authorization server. + :paramtype client_id: str + :keyword client_secret: Client or app secret registered with this authorization server. This + property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the + value. + :paramtype client_secret: str + """ super(AuthorizationServerUpdateContract, self).__init__(**kwargs) self.description = description self.authorization_methods = authorization_methods @@ -4237,59 +6042,61 @@ def __init__( class AuthorizationServerUpdateContractProperties(AuthorizationServerContractBaseProperties): """External OAuth authorization server Update settings contract. - :param description: Description of the authorization server. Can contain HTML formatting tags. - :type description: str - :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + :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. - :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :param 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, + :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. - :type client_authentication_method: list[str or + :vartype client_authentication_method: list[str or ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :param token_body_parameters: Additional parameters required by the token endpoint of this + :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"}. - :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. - :type token_endpoint: str - :param support_state: If true, authorization server will include state parameter from the + :vartype token_body_parameters: + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :ivar token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. + :vartype token_endpoint: str + :ivar support_state: If true, authorization server will include state parameter from the authorization request to its response. Client may use state parameter to raise protocol security. - :type support_state: bool - :param default_scope: Access token scope that is going to be requested by default. Can be + :vartype support_state: bool + :ivar default_scope: Access token scope that is going to be requested by default. Can be overridden at the API level. Should be provided in the form of a string containing space-delimited values. - :type default_scope: str - :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to + :vartype default_scope: str + :ivar bearer_token_sending_methods: Specifies the mechanism by which access token is passed to the API. - :type bearer_token_sending_methods: list[str or + :vartype bearer_token_sending_methods: list[str or ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :param resource_owner_username: Can be optionally specified when resource owner password grant + :ivar resource_owner_username: Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. - :type resource_owner_username: str - :param resource_owner_password: Can be optionally specified when resource owner password grant + :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. - :type resource_owner_password: str - :param display_name: User-friendly authorization server name. - :type display_name: str - :param client_registration_endpoint: Optional reference to a page where client or app + :vartype resource_owner_password: str + :ivar display_name: User-friendly authorization server name. + :vartype display_name: str + :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. - :type client_registration_endpoint: str - :param authorization_endpoint: OAuth authorization endpoint. See + :vartype client_registration_endpoint: str + :ivar authorization_endpoint: OAuth authorization endpoint. See http://tools.ietf.org/html/rfc6749#section-3.2. - :type authorization_endpoint: str - :param grant_types: Form of an authorization grant, which the client uses to request the access + :vartype authorization_endpoint: str + :ivar grant_types: Form of an authorization grant, which the client uses to request the access token. - :type grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :param client_id: Client or app id registered with this authorization server. - :type client_id: str - :param client_secret: Client or app secret registered with this authorization server. This + :vartype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] + :ivar client_id: Client or app id registered with this authorization server. + :vartype client_id: str + :ivar client_secret: Client or app secret registered with this authorization server. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. - :type client_secret: str + :vartype client_secret: str """ _validation = { @@ -4336,6 +6143,65 @@ def __init__( client_secret: Optional[str] = None, **kwargs ): + """ + :keyword description: Description of the authorization server. Can contain HTML formatting + tags. + :paramtype description: str + :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + always present. POST is optional. + :paramtype authorization_methods: list[str or + ~azure.mgmt.apimanagement.models.AuthorizationMethod] + :keyword client_authentication_method: Method of authentication supported by the token endpoint + of this authorization server. Possible values are Basic and/or Body. When Body is specified, + client credentials and other parameters are passed within the request body in the + application/x-www-form-urlencoded format. + :paramtype client_authentication_method: list[str or + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] + :keyword token_body_parameters: Additional parameters required by the token endpoint of this + authorization server represented as an array of JSON objects with name and value string + properties, i.e. {"name" : "name value", "value": "a value"}. + :paramtype token_body_parameters: + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being + referenced. + :paramtype token_endpoint: str + :keyword support_state: If true, authorization server will include state parameter from the + authorization request to its response. Client may use state parameter to raise protocol + security. + :paramtype support_state: bool + :keyword default_scope: Access token scope that is going to be requested by default. Can be + overridden at the API level. Should be provided in the form of a string containing + space-delimited values. + :paramtype default_scope: str + :keyword bearer_token_sending_methods: Specifies the mechanism by which access token is passed + to the API. + :paramtype bearer_token_sending_methods: list[str or + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] + :keyword resource_owner_username: Can be optionally specified when resource owner password + grant type is supported by this authorization server. Default resource owner username. + :paramtype resource_owner_username: str + :keyword resource_owner_password: Can be optionally specified when resource owner password + grant type is supported by this authorization server. Default resource owner password. + :paramtype resource_owner_password: str + :keyword display_name: User-friendly authorization server name. + :paramtype display_name: str + :keyword client_registration_endpoint: Optional reference to a page where client or app + registration for this authorization server is performed. Contains absolute URL to entity being + referenced. + :paramtype client_registration_endpoint: str + :keyword authorization_endpoint: OAuth authorization endpoint. See + http://tools.ietf.org/html/rfc6749#section-3.2. + :paramtype authorization_endpoint: str + :keyword grant_types: Form of an authorization grant, which the client uses to request the + access token. + :paramtype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] + :keyword client_id: Client or app id registered with this authorization server. + :paramtype client_id: str + :keyword client_secret: Client or app secret registered with this authorization server. This + property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the + value. + :paramtype client_secret: str + """ super(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) self.display_name = display_name self.client_registration_endpoint = client_registration_endpoint @@ -4350,10 +6216,10 @@ class BackendAuthorizationHeaderCredentials(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param scheme: Required. Authentication Scheme name. - :type scheme: str - :param parameter: Required. Authentication Parameter value. - :type parameter: str + :ivar scheme: Required. Authentication Scheme name. + :vartype scheme: str + :ivar parameter: Required. Authentication Parameter value. + :vartype parameter: str """ _validation = { @@ -4373,6 +6239,12 @@ def __init__( parameter: str, **kwargs ): + """ + :keyword scheme: Required. Authentication Scheme name. + :paramtype scheme: str + :keyword parameter: Required. Authentication Parameter value. + :paramtype parameter: str + """ super(BackendAuthorizationHeaderCredentials, self).__init__(**kwargs) self.scheme = scheme self.parameter = parameter @@ -4381,21 +6253,21 @@ def __init__( class BackendBaseParameters(msrest.serialization.Model): """Backend entity base Parameter set. - :param title: Backend Title. - :type title: str - :param description: Backend Description. - :type description: str - :param resource_id: Management Uri of the Resource in External System. This url can be the Arm - Resource Id of Logic Apps, Function Apps or Api Apps. - :type resource_id: str - :param properties: Backend Properties contract. - :type properties: ~azure.mgmt.apimanagement.models.BackendProperties - :param credentials: Backend Credentials Contract Properties. - :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :param proxy: Backend Proxy Contract Properties. - :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract - :param tls: Backend TLS Properties. - :type tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + :ivar title: Backend Title. + :vartype title: str + :ivar description: Backend Description. + :vartype description: str + :ivar resource_id: Management Uri of the Resource in External System. This url can be the Arm + Resource Id of Logic Apps, Function Apps or API Apps. + :vartype resource_id: str + :ivar properties: Backend Properties contract. + :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties + :ivar credentials: Backend Credentials Contract Properties. + :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :ivar proxy: Backend Proxy Contract Properties. + :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract + :ivar tls: Backend TLS Properties. + :vartype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties """ _validation = { @@ -4426,6 +6298,23 @@ def __init__( tls: Optional["BackendTlsProperties"] = None, **kwargs ): + """ + :keyword title: Backend Title. + :paramtype title: str + :keyword description: Backend Description. + :paramtype description: str + :keyword resource_id: Management Uri of the Resource in External System. This url can be the + Arm Resource Id of Logic Apps, Function Apps or API Apps. + :paramtype resource_id: str + :keyword properties: Backend Properties contract. + :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties + :keyword credentials: Backend Credentials Contract Properties. + :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :keyword proxy: Backend Proxy Contract Properties. + :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract + :keyword tls: Backend TLS Properties. + :paramtype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + """ super(BackendBaseParameters, self).__init__(**kwargs) self.title = title self.description = description @@ -4439,12 +6328,12 @@ def __init__( class BackendCollection(msrest.serialization.Model): """Paged Backend list representation. - :param value: Backend values. - :type value: list[~azure.mgmt.apimanagement.models.BackendContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Backend values. + :vartype value: list[~azure.mgmt.apimanagement.models.BackendContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -4461,6 +6350,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Backend values. + :paramtype value: list[~azure.mgmt.apimanagement.models.BackendContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(BackendCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -4472,31 +6369,33 @@ class BackendContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param title: Backend Title. - :type title: str - :param description: Backend Description. - :type description: str - :param resource_id: Management Uri of the Resource in External System. This url can be the Arm - Resource Id of Logic Apps, Function Apps or Api Apps. - :type resource_id: str - :param properties: Backend Properties contract. - :type properties: ~azure.mgmt.apimanagement.models.BackendProperties - :param credentials: Backend Credentials Contract Properties. - :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :param proxy: Backend Proxy Contract Properties. - :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract - :param tls: Backend TLS Properties. - :type tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties - :param url: Runtime Url of the Backend. - :type url: str - :param protocol: Backend communication protocol. Possible values include: "http", "soap". - :type protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol + :ivar title: Backend Title. + :vartype title: str + :ivar description: Backend Description. + :vartype description: str + :ivar resource_id: Management Uri of the Resource in External System. This url can be the Arm + Resource Id of Logic Apps, Function Apps or API Apps. + :vartype resource_id: str + :ivar properties: Backend Properties contract. + :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties + :ivar credentials: Backend Credentials Contract Properties. + :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :ivar proxy: Backend Proxy Contract Properties. + :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract + :ivar tls: Backend TLS Properties. + :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 ~azure.mgmt.apimanagement.models.BackendProtocol """ _validation = { @@ -4538,6 +6437,27 @@ def __init__( protocol: Optional[Union[str, "BackendProtocol"]] = None, **kwargs ): + """ + :keyword title: Backend Title. + :paramtype title: str + :keyword description: Backend Description. + :paramtype description: str + :keyword resource_id: Management Uri of the Resource in External System. This url can be the + Arm Resource Id of Logic Apps, Function Apps or API Apps. + :paramtype resource_id: str + :keyword properties: Backend Properties contract. + :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties + :keyword credentials: Backend Credentials Contract Properties. + :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :keyword proxy: Backend Proxy Contract Properties. + :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract + :keyword tls: Backend TLS Properties. + :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 ~azure.mgmt.apimanagement.models.BackendProtocol + """ super(BackendContract, self).__init__(**kwargs) self.title = title self.description = description @@ -4555,26 +6475,26 @@ class BackendContractProperties(BackendBaseParameters): All required parameters must be populated in order to send to Azure. - :param title: Backend Title. - :type title: str - :param description: Backend Description. - :type description: str - :param resource_id: Management Uri of the Resource in External System. This url can be the Arm - Resource Id of Logic Apps, Function Apps or Api Apps. - :type resource_id: str - :param properties: Backend Properties contract. - :type properties: ~azure.mgmt.apimanagement.models.BackendProperties - :param credentials: Backend Credentials Contract Properties. - :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :param proxy: Backend Proxy Contract Properties. - :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract - :param tls: Backend TLS Properties. - :type tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties - :param url: Required. Runtime Url of the Backend. - :type url: str - :param protocol: Required. Backend communication protocol. Possible values include: "http", + :ivar title: Backend Title. + :vartype title: str + :ivar description: Backend Description. + :vartype description: str + :ivar resource_id: Management Uri of the Resource in External System. This url can be the Arm + Resource Id of Logic Apps, Function Apps or API Apps. + :vartype resource_id: str + :ivar properties: Backend Properties contract. + :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties + :ivar credentials: Backend Credentials Contract Properties. + :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :ivar proxy: Backend Proxy Contract Properties. + :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract + :ivar tls: Backend TLS Properties. + :vartype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + :ivar url: Required. Runtime Url of the Backend. + :vartype url: str + :ivar protocol: Required. Backend communication protocol. Possible values include: "http", "soap". - :type protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol + :vartype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol """ _validation = { @@ -4611,6 +6531,28 @@ def __init__( tls: Optional["BackendTlsProperties"] = None, **kwargs ): + """ + :keyword title: Backend Title. + :paramtype title: str + :keyword description: Backend Description. + :paramtype description: str + :keyword resource_id: Management Uri of the Resource in External System. This url can be the + Arm Resource Id of Logic Apps, Function Apps or API Apps. + :paramtype resource_id: str + :keyword properties: Backend Properties contract. + :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties + :keyword credentials: Backend Credentials Contract Properties. + :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :keyword proxy: Backend Proxy Contract Properties. + :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract + :keyword tls: Backend TLS Properties. + :paramtype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + :keyword url: Required. Runtime Url of the Backend. + :paramtype url: str + :keyword protocol: Required. Backend communication protocol. Possible values include: "http", + "soap". + :paramtype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol + """ super(BackendContractProperties, self).__init__(title=title, description=description, resource_id=resource_id, properties=properties, credentials=credentials, proxy=proxy, tls=tls, **kwargs) self.url = url self.protocol = protocol @@ -4619,17 +6561,17 @@ def __init__( class BackendCredentialsContract(msrest.serialization.Model): """Details of the Credentials used to connect to Backend. - :param certificate_ids: List of Client Certificate Ids. - :type certificate_ids: list[str] - :param certificate: List of Client Certificate Thumbprints. Will be ignored if certificatesIds + :ivar certificate_ids: List of Client Certificate Ids. + :vartype certificate_ids: list[str] + :ivar certificate: List of Client Certificate Thumbprints. Will be ignored if certificatesIds are provided. - :type certificate: list[str] - :param query: Query Parameter description. - :type query: dict[str, list[str]] - :param header: Header Parameter description. - :type header: dict[str, list[str]] - :param authorization: Authorization header authentication. - :type authorization: ~azure.mgmt.apimanagement.models.BackendAuthorizationHeaderCredentials + :vartype certificate: list[str] + :ivar query: Query Parameter description. + :vartype query: dict[str, list[str]] + :ivar header: Header Parameter description. + :vartype header: dict[str, list[str]] + :ivar authorization: Authorization header authentication. + :vartype authorization: ~azure.mgmt.apimanagement.models.BackendAuthorizationHeaderCredentials """ _validation = { @@ -4655,6 +6597,20 @@ def __init__( authorization: Optional["BackendAuthorizationHeaderCredentials"] = None, **kwargs ): + """ + :keyword certificate_ids: List of Client Certificate Ids. + :paramtype certificate_ids: list[str] + :keyword certificate: List of Client Certificate Thumbprints. Will be ignored if + certificatesIds are provided. + :paramtype certificate: list[str] + :keyword query: Query Parameter description. + :paramtype query: dict[str, list[str]] + :keyword header: Header Parameter description. + :paramtype header: dict[str, list[str]] + :keyword authorization: Authorization header authentication. + :paramtype authorization: + ~azure.mgmt.apimanagement.models.BackendAuthorizationHeaderCredentials + """ super(BackendCredentialsContract, self).__init__(**kwargs) self.certificate_ids = certificate_ids self.certificate = certificate @@ -4666,8 +6622,8 @@ def __init__( class BackendProperties(msrest.serialization.Model): """Properties specific to the Backend Type. - :param service_fabric_cluster: Backend Service Fabric Cluster Properties. - :type service_fabric_cluster: + :ivar service_fabric_cluster: Backend Service Fabric Cluster Properties. + :vartype service_fabric_cluster: ~azure.mgmt.apimanagement.models.BackendServiceFabricClusterProperties """ @@ -4681,6 +6637,11 @@ def __init__( service_fabric_cluster: Optional["BackendServiceFabricClusterProperties"] = None, **kwargs ): + """ + :keyword service_fabric_cluster: Backend Service Fabric Cluster Properties. + :paramtype service_fabric_cluster: + ~azure.mgmt.apimanagement.models.BackendServiceFabricClusterProperties + """ super(BackendProperties, self).__init__(**kwargs) self.service_fabric_cluster = service_fabric_cluster @@ -4690,13 +6651,13 @@ class BackendProxyContract(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param url: Required. WebProxy Server AbsoluteUri property which includes the entire URI stored + :ivar url: Required. WebProxy Server AbsoluteUri property which includes the entire URI stored in the Uri instance, including all fragments and query strings. - :type url: str - :param username: Username to connect to the WebProxy server. - :type username: str - :param password: Password to connect to the WebProxy Server. - :type password: str + :vartype url: str + :ivar username: Username to connect to the WebProxy server. + :vartype username: str + :ivar password: Password to connect to the WebProxy Server. + :vartype password: str """ _validation = { @@ -4717,6 +6678,15 @@ def __init__( 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. + :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) self.url = url self.username = username @@ -4728,15 +6698,17 @@ class BackendReconnectContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param after: Duration in ISO8601 format after which reconnect will be initiated. Minimum + :ivar after: Duration in ISO8601 format after which reconnect will be initiated. Minimum duration of the Reconnect is PT2M. - :type after: ~datetime.timedelta + :vartype after: ~datetime.timedelta """ _validation = { @@ -4758,6 +6730,11 @@ def __init__( 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) self.after = after @@ -4767,21 +6744,21 @@ class BackendServiceFabricClusterProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param client_certificate_id: The client certificate id for the management endpoint. - :type client_certificate_id: str - :param client_certificatethumbprint: The client certificate thumbprint for the management + :ivar client_certificate_id: The client certificate id for the management endpoint. + :vartype client_certificate_id: str + :ivar client_certificatethumbprint: The client certificate thumbprint for the management endpoint. Will be ignored if certificatesIds are provided. - :type client_certificatethumbprint: str - :param max_partition_resolution_retries: Maximum number of retries while attempting resolve the + :vartype client_certificatethumbprint: str + :ivar max_partition_resolution_retries: Maximum number of retries while attempting resolve the partition. - :type max_partition_resolution_retries: int - :param management_endpoints: Required. The cluster management endpoint. - :type management_endpoints: list[str] - :param server_certificate_thumbprints: Thumbprints of certificates cluster management service + :vartype max_partition_resolution_retries: int + :ivar management_endpoints: Required. The cluster management endpoint. + :vartype management_endpoints: list[str] + :ivar server_certificate_thumbprints: Thumbprints of certificates cluster management service uses for tls communication. - :type server_certificate_thumbprints: list[str] - :param server_x509_names: Server X509 Certificate Names Collection. - :type server_x509_names: list[~azure.mgmt.apimanagement.models.X509CertificateName] + :vartype server_certificate_thumbprints: list[str] + :ivar server_x509_names: Server X509 Certificate Names Collection. + :vartype server_x509_names: list[~azure.mgmt.apimanagement.models.X509CertificateName] """ _validation = { @@ -4808,6 +6785,23 @@ def __init__( server_x509_names: Optional[List["X509CertificateName"]] = None, **kwargs ): + """ + :keyword client_certificate_id: The client certificate id for the management endpoint. + :paramtype client_certificate_id: str + :keyword client_certificatethumbprint: The client certificate thumbprint for the management + endpoint. Will be ignored if certificatesIds are provided. + :paramtype client_certificatethumbprint: str + :keyword max_partition_resolution_retries: Maximum number of retries while attempting resolve + the partition. + :paramtype max_partition_resolution_retries: int + :keyword management_endpoints: Required. The cluster management endpoint. + :paramtype management_endpoints: list[str] + :keyword server_certificate_thumbprints: Thumbprints of certificates cluster management service + uses for tls communication. + :paramtype server_certificate_thumbprints: list[str] + :keyword server_x509_names: Server X509 Certificate Names Collection. + :paramtype server_x509_names: list[~azure.mgmt.apimanagement.models.X509CertificateName] + """ super(BackendServiceFabricClusterProperties, self).__init__(**kwargs) self.client_certificate_id = client_certificate_id self.client_certificatethumbprint = client_certificatethumbprint @@ -4820,12 +6814,12 @@ def __init__( class BackendTlsProperties(msrest.serialization.Model): """Properties controlling TLS Certificate Validation. - :param validate_certificate_chain: Flag indicating whether SSL certificate chain validation + :ivar validate_certificate_chain: Flag indicating whether SSL certificate chain validation should be done when using self-signed certificates for this backend host. - :type validate_certificate_chain: bool - :param validate_certificate_name: Flag indicating whether SSL certificate name validation - should be done when using self-signed certificates for this backend host. - :type validate_certificate_name: bool + :vartype validate_certificate_chain: bool + :ivar validate_certificate_name: Flag indicating whether SSL certificate name validation should + be done when using self-signed certificates for this backend host. + :vartype validate_certificate_name: bool """ _attribute_map = { @@ -4840,6 +6834,14 @@ def __init__( validate_certificate_name: Optional[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. + :paramtype validate_certificate_chain: bool + :keyword validate_certificate_name: Flag indicating whether SSL certificate name validation + should be done when using self-signed certificates for this backend host. + :paramtype validate_certificate_name: bool + """ super(BackendTlsProperties, self).__init__(**kwargs) self.validate_certificate_chain = validate_certificate_chain self.validate_certificate_name = validate_certificate_name @@ -4848,25 +6850,25 @@ def __init__( class BackendUpdateParameterProperties(BackendBaseParameters): """Parameters supplied to the Update Backend operation. - :param title: Backend Title. - :type title: str - :param description: Backend Description. - :type description: str - :param resource_id: Management Uri of the Resource in External System. This url can be the Arm - Resource Id of Logic Apps, Function Apps or Api Apps. - :type resource_id: str - :param properties: Backend Properties contract. - :type properties: ~azure.mgmt.apimanagement.models.BackendProperties - :param credentials: Backend Credentials Contract Properties. - :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :param proxy: Backend Proxy Contract Properties. - :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract - :param tls: Backend TLS Properties. - :type tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties - :param url: Runtime Url of the Backend. - :type url: str - :param protocol: Backend communication protocol. Possible values include: "http", "soap". - :type protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol + :ivar title: Backend Title. + :vartype title: str + :ivar description: Backend Description. + :vartype description: str + :ivar resource_id: Management Uri of the Resource in External System. This url can be the Arm + Resource Id of Logic Apps, Function Apps or API Apps. + :vartype resource_id: str + :ivar properties: Backend Properties contract. + :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties + :ivar credentials: Backend Credentials Contract Properties. + :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :ivar proxy: Backend Proxy Contract Properties. + :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract + :ivar tls: Backend TLS Properties. + :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 ~azure.mgmt.apimanagement.models.BackendProtocol """ _validation = { @@ -4902,6 +6904,27 @@ def __init__( protocol: Optional[Union[str, "BackendProtocol"]] = None, **kwargs ): + """ + :keyword title: Backend Title. + :paramtype title: str + :keyword description: Backend Description. + :paramtype description: str + :keyword resource_id: Management Uri of the Resource in External System. This url can be the + Arm Resource Id of Logic Apps, Function Apps or API Apps. + :paramtype resource_id: str + :keyword properties: Backend Properties contract. + :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties + :keyword credentials: Backend Credentials Contract Properties. + :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :keyword proxy: Backend Proxy Contract Properties. + :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract + :keyword tls: Backend TLS Properties. + :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 ~azure.mgmt.apimanagement.models.BackendProtocol + """ super(BackendUpdateParameterProperties, self).__init__(title=title, description=description, resource_id=resource_id, properties=properties, credentials=credentials, proxy=proxy, tls=tls, **kwargs) self.url = url self.protocol = protocol @@ -4910,25 +6933,25 @@ def __init__( class BackendUpdateParameters(msrest.serialization.Model): """Backend update parameters. - :param title: Backend Title. - :type title: str - :param description: Backend Description. - :type description: str - :param resource_id: Management Uri of the Resource in External System. This url can be the Arm - Resource Id of Logic Apps, Function Apps or Api Apps. - :type resource_id: str - :param properties: Backend Properties contract. - :type properties: ~azure.mgmt.apimanagement.models.BackendProperties - :param credentials: Backend Credentials Contract Properties. - :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :param proxy: Backend Proxy Contract Properties. - :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract - :param tls: Backend TLS Properties. - :type tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties - :param url: Runtime Url of the Backend. - :type url: str - :param protocol: Backend communication protocol. Possible values include: "http", "soap". - :type protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol + :ivar title: Backend Title. + :vartype title: str + :ivar description: Backend Description. + :vartype description: str + :ivar resource_id: Management Uri of the Resource in External System. This url can be the Arm + Resource Id of Logic Apps, Function Apps or API Apps. + :vartype resource_id: str + :ivar properties: Backend Properties contract. + :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties + :ivar credentials: Backend Credentials Contract Properties. + :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :ivar proxy: Backend Proxy Contract Properties. + :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract + :ivar tls: Backend TLS Properties. + :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 ~azure.mgmt.apimanagement.models.BackendProtocol """ _validation = { @@ -4964,6 +6987,27 @@ def __init__( protocol: Optional[Union[str, "BackendProtocol"]] = None, **kwargs ): + """ + :keyword title: Backend Title. + :paramtype title: str + :keyword description: Backend Description. + :paramtype description: str + :keyword resource_id: Management Uri of the Resource in External System. This url can be the + Arm Resource Id of Logic Apps, Function Apps or API Apps. + :paramtype resource_id: str + :keyword properties: Backend Properties contract. + :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties + :keyword credentials: Backend Credentials Contract Properties. + :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :keyword proxy: Backend Proxy Contract Properties. + :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract + :keyword tls: Backend TLS Properties. + :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 ~azure.mgmt.apimanagement.models.BackendProtocol + """ super(BackendUpdateParameters, self).__init__(**kwargs) self.title = title self.description = description @@ -4979,8 +7023,8 @@ def __init__( class BodyDiagnosticSettings(msrest.serialization.Model): """Body logging settings. - :param bytes: Number of request body bytes to log. - :type bytes: int + :ivar bytes: Number of request body bytes to log. + :vartype bytes: int """ _validation = { @@ -4997,6 +7041,10 @@ def __init__( bytes: Optional[int] = None, **kwargs ): + """ + :keyword bytes: Number of request body bytes to log. + :paramtype bytes: int + """ super(BodyDiagnosticSettings, self).__init__(**kwargs) self.bytes = bytes @@ -5004,12 +7052,12 @@ def __init__( class CacheCollection(msrest.serialization.Model): """Paged Caches list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.CacheContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.CacheContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -5026,6 +7074,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.CacheContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(CacheCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -5037,21 +7093,23 @@ class CacheContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param description: Cache description. - :type description: str - :param connection_string: Runtime connection string to cache. - :type connection_string: str - :param use_from_location: Location identifier to use cache from (should be either 'default' or + :ivar description: Cache description. + :vartype description: str + :ivar connection_string: Runtime connection string to cache. + :vartype connection_string: str + :ivar use_from_location: Location identifier to use cache from (should be either 'default' or valid Azure region identifier). - :type use_from_location: str - :param resource_id: Original uri of entity in external system cache points to. - :type resource_id: str + :vartype use_from_location: str + :ivar resource_id: Original uri of entity in external system cache points to. + :vartype resource_id: str """ _validation = { @@ -5083,6 +7141,17 @@ def __init__( resource_id: Optional[str] = None, **kwargs ): + """ + :keyword description: Cache description. + :paramtype description: str + :keyword connection_string: Runtime connection string to cache. + :paramtype connection_string: str + :keyword use_from_location: Location identifier to use cache from (should be either 'default' + or valid Azure region identifier). + :paramtype use_from_location: str + :keyword resource_id: Original uri of entity in external system cache points to. + :paramtype resource_id: str + """ super(CacheContract, self).__init__(**kwargs) self.description = description self.connection_string = connection_string @@ -5093,15 +7162,15 @@ def __init__( class CacheUpdateParameters(msrest.serialization.Model): """Cache update details. - :param description: Cache description. - :type description: str - :param connection_string: Runtime connection string to cache. - :type connection_string: str - :param use_from_location: Location identifier to use cache from (should be either 'default' or + :ivar description: Cache description. + :vartype description: str + :ivar connection_string: Runtime connection string to cache. + :vartype connection_string: str + :ivar use_from_location: Location identifier to use cache from (should be either 'default' or valid Azure region identifier). - :type use_from_location: str - :param resource_id: Original uri of entity in external system cache points to. - :type resource_id: str + :vartype use_from_location: str + :ivar resource_id: Original uri of entity in external system cache points to. + :vartype resource_id: str """ _validation = { @@ -5127,6 +7196,17 @@ def __init__( resource_id: Optional[str] = None, **kwargs ): + """ + :keyword description: Cache description. + :paramtype description: str + :keyword connection_string: Runtime connection string to cache. + :paramtype connection_string: str + :keyword use_from_location: Location identifier to use cache from (should be either 'default' + or valid Azure region identifier). + :paramtype use_from_location: str + :keyword resource_id: Original uri of entity in external system cache points to. + :paramtype resource_id: str + """ super(CacheUpdateParameters, self).__init__(**kwargs) self.description = description self.connection_string = connection_string @@ -5137,12 +7217,12 @@ def __init__( class CertificateCollection(msrest.serialization.Model): """Paged Certificates list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.CertificateContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.CertificateContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -5159,6 +7239,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.CertificateContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(CertificateCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -5170,16 +7258,16 @@ class CertificateConfiguration(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param encoded_certificate: Base64 Encoded certificate. - :type encoded_certificate: str - :param certificate_password: Certificate Password. - :type certificate_password: str - :param store_name: Required. The System.Security.Cryptography.x509certificates.StoreName + :ivar encoded_certificate: Base64 Encoded certificate. + :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". - :type store_name: str or ~azure.mgmt.apimanagement.models.CertificateConfigurationStoreName - :param certificate: Certificate information. - :type certificate: ~azure.mgmt.apimanagement.models.CertificateInformation + :vartype store_name: str or ~azure.mgmt.apimanagement.models.CertificateConfigurationStoreName + :ivar certificate: Certificate information. + :vartype certificate: ~azure.mgmt.apimanagement.models.CertificateInformation """ _validation = { @@ -5202,6 +7290,19 @@ def __init__( certificate: Optional["CertificateInformation"] = None, **kwargs ): + """ + :keyword encoded_certificate: Base64 Encoded certificate. + :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 + ~azure.mgmt.apimanagement.models.CertificateConfigurationStoreName + :keyword certificate: Certificate information. + :paramtype certificate: ~azure.mgmt.apimanagement.models.CertificateInformation + """ super(CertificateConfiguration, self).__init__(**kwargs) self.encoded_certificate = encoded_certificate self.certificate_password = certificate_password @@ -5214,21 +7315,23 @@ class CertificateContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param subject: Subject attribute of the certificate. - :type subject: str - :param thumbprint: Thumbprint of the certificate. - :type thumbprint: str - :param expiration_date: Expiration date of the certificate. The date conforms to the following + :ivar subject: Subject attribute of the certificate. + :vartype subject: str + :ivar thumbprint: Thumbprint of the certificate. + :vartype thumbprint: str + :ivar expiration_date: Expiration date of the certificate. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type expiration_date: ~datetime.datetime - :param key_vault: KeyVault location details of the certificate. - :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties + :vartype expiration_date: ~datetime.datetime + :ivar key_vault: KeyVault location details of the certificate. + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties """ _validation = { @@ -5256,6 +7359,17 @@ def __init__( key_vault: Optional["KeyVaultContractProperties"] = None, **kwargs ): + """ + :keyword subject: Subject attribute of the certificate. + :paramtype subject: str + :keyword thumbprint: Thumbprint of the certificate. + :paramtype thumbprint: str + :keyword expiration_date: Expiration date of the certificate. The date conforms to the + following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :paramtype expiration_date: ~datetime.datetime + :keyword key_vault: KeyVault location details of the certificate. + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties + """ super(CertificateContract, self).__init__(**kwargs) self.subject = subject self.thumbprint = thumbprint @@ -5266,12 +7380,12 @@ def __init__( class CertificateCreateOrUpdateParameters(msrest.serialization.Model): """Certificate create or update details. - :param data: Base 64 encoded certificate using the application/x-pkcs12 representation. - :type data: str - :param password: Password for the Certificate. - :type password: str - :param key_vault: KeyVault location details of the certificate. - :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties + :ivar data: Base 64 encoded certificate using the application/x-pkcs12 representation. + :vartype data: str + :ivar password: Password for the Certificate. + :vartype password: str + :ivar key_vault: KeyVault location details of the certificate. + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ _attribute_map = { @@ -5288,6 +7402,14 @@ def __init__( key_vault: Optional["KeyVaultContractCreateProperties"] = None, **kwargs ): + """ + :keyword data: Base 64 encoded certificate using the application/x-pkcs12 representation. + :paramtype data: str + :keyword password: Password for the Certificate. + :paramtype password: str + :keyword key_vault: KeyVault location details of the certificate. + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties + """ super(CertificateCreateOrUpdateParameters, self).__init__(**kwargs) self.data = data self.password = password @@ -5299,13 +7421,13 @@ class CertificateInformation(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param expiry: Required. Expiration date of the certificate. The date conforms to the following + :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. - :type expiry: ~datetime.datetime - :param thumbprint: Required. Thumbprint of the certificate. - :type thumbprint: str - :param subject: Required. Subject of the certificate. - :type subject: str + :vartype expiry: ~datetime.datetime + :ivar thumbprint: Required. Thumbprint of the certificate. + :vartype thumbprint: str + :ivar subject: Required. Subject of the certificate. + :vartype subject: str """ _validation = { @@ -5328,6 +7450,15 @@ def __init__( 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. + :paramtype expiry: ~datetime.datetime + :keyword thumbprint: Required. Thumbprint of the certificate. + :paramtype thumbprint: str + :keyword subject: Required. Subject of the certificate. + :paramtype subject: str + """ super(CertificateInformation, self).__init__(**kwargs) self.expiry = expiry self.thumbprint = thumbprint @@ -5337,8 +7468,8 @@ def __init__( class ClientSecretContract(msrest.serialization.Model): """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. - :param client_secret: Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. - :type client_secret: str + :ivar client_secret: Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. + :vartype client_secret: str """ _attribute_map = { @@ -5351,123 +7482,523 @@ def __init__( 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) self.client_secret = client_secret -class ConnectivityStatusContract(msrest.serialization.Model): - """Details about connectivity to a resource. +class ConnectivityCheckRequest(msrest.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. - :param 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. - :type name: str - :param status: Required. Resource Connectivity Status Type identifier. Possible values include: - "initializing", "success", "failure". - :type status: str or ~azure.mgmt.apimanagement.models.ConnectivityStatusType - :param error: Error details of the connectivity to the resource. - :type error: str - :param 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. - :type last_updated: ~datetime.datetime - :param 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. - :type last_status_change: ~datetime.datetime - :param resource_type: Required. Resource Type. - :type resource_type: str - :param is_optional: Required. Whether this is optional. - :type is_optional: bool + :ivar source: Required. Definitions about the connectivity check origin. + :vartype source: ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestSource + :ivar destination: Required. The connectivity check operation destination. + :vartype destination: ~azure.mgmt.apimanagement.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 ~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 ~azure.mgmt.apimanagement.models.ConnectivityCheckProtocol + :ivar protocol_configuration: Protocol-specific configuration. + :vartype protocol_configuration: + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfiguration """ _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}, + 'source': {'required': True}, + 'destination': {'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'}, + '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, *, - name: str, - status: Union[str, "ConnectivityStatusType"], - last_updated: datetime.datetime, - last_status_change: datetime.datetime, - resource_type: str, - is_optional: bool, - error: Optional[str] = None, - **kwargs - ): - super(ConnectivityStatusContract, self).__init__(**kwargs) - self.name = name - self.status = status - self.error = error - self.last_updated = last_updated - self.last_status_change = last_status_change - self.resource_type = resource_type - self.is_optional = is_optional + source: "ConnectivityCheckRequestSource", + destination: "ConnectivityCheckRequestDestination", + preferred_ip_version: Optional[Union[str, "PreferredIPVersion"]] = None, + protocol: Optional[Union[str, "ConnectivityCheckProtocol"]] = None, + protocol_configuration: Optional["ConnectivityCheckRequestProtocolConfiguration"] = None, + **kwargs + ): + """ + :keyword source: Required. Definitions about the connectivity check origin. + :paramtype source: ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestSource + :keyword destination: Required. The connectivity check operation destination. + :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 ~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 ~azure.mgmt.apimanagement.models.ConnectivityCheckProtocol + :keyword protocol_configuration: Protocol-specific configuration. + :paramtype protocol_configuration: + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfiguration + """ + super(ConnectivityCheckRequest, self).__init__(**kwargs) + self.source = source + self.destination = destination + self.preferred_ip_version = preferred_ip_version + self.protocol = protocol + self.protocol_configuration = protocol_configuration -class ContentItemCollection(msrest.serialization.Model): - """Paged list of content items. +class ConnectivityCheckRequestDestination(msrest.serialization.Model): + """The connectivity check operation destination. - 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: Collection of content items. - :vartype value: list[~azure.mgmt.apimanagement.models.ContentItemContract] - :ivar next_link: Next page link, if any. - :vartype next_link: str + :ivar address: Required. Destination address. Can either be an IP address or a FQDN. + :vartype address: str + :ivar port: Required. Destination port. + :vartype port: long """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + 'address': {'required': True}, + 'port': {'required': True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ContentItemContract]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'address': {'key': 'address', 'type': 'str'}, + 'port': {'key': 'port', 'type': 'long'}, } def __init__( self, + *, + address: str, + port: int, **kwargs ): - super(ContentItemCollection, self).__init__(**kwargs) - self.value = None - self.next_link = None + """ + :keyword address: Required. Destination address. Can either be an IP address or a FQDN. + :paramtype address: str + :keyword port: Required. Destination port. + :paramtype port: long + """ + super(ConnectivityCheckRequestDestination, self).__init__(**kwargs) + self.address = address + self.port = port -class ContentItemContract(Resource): - """Content type contract details. +class ConnectivityCheckRequestProtocolConfiguration(msrest.serialization.Model): + """Protocol-specific configuration. - Variables are only populated by the server, and will be ignored when sending a request. + :ivar http_configuration: Configuration for HTTP or HTTPS requests. + :vartype http_configuration: + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration + """ - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. + _attribute_map = { + 'http_configuration': {'key': 'HTTPConfiguration', 'type': 'ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration'}, + } + + def __init__( + self, + *, + http_configuration: Optional["ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration"] = None, + **kwargs + ): + """ + :keyword http_configuration: Configuration for HTTP or HTTPS requests. + :paramtype http_configuration: + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration + """ + super(ConnectivityCheckRequestProtocolConfiguration, self).__init__(**kwargs) + self.http_configuration = http_configuration + + +class ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration(msrest.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 ~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] + :ivar headers: List of headers to be included in the request. + :vartype headers: list[~azure.mgmt.apimanagement.models.HTTPHeader] + """ + + _attribute_map = { + 'method': {'key': 'method', 'type': 'str'}, + 'valid_status_codes': {'key': 'validStatusCodes', 'type': '[long]'}, + 'headers': {'key': 'headers', 'type': '[HTTPHeader]'}, + } + + def __init__( + self, + *, + method: Optional[Union[str, "Method"]] = None, + valid_status_codes: Optional[List[int]] = None, + headers: Optional[List["HTTPHeader"]] = None, + **kwargs + ): + """ + :keyword method: The HTTP method to be used. Possible values include: "GET", "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] + :keyword headers: List of headers to be included in the request. + :paramtype headers: list[~azure.mgmt.apimanagement.models.HTTPHeader] + """ + super(ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration, self).__init__(**kwargs) + self.method = method + self.valid_status_codes = valid_status_codes + self.headers = headers + + +class ConnectivityCheckRequestSource(msrest.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. + :vartype region: str + :ivar instance: The particular VMSS instance from which to fire the request. + :vartype instance: long + """ + + _validation = { + 'region': {'required': True}, + } + + _attribute_map = { + 'region': {'key': 'region', 'type': 'str'}, + 'instance': {'key': 'instance', 'type': 'long'}, + } + + 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. + :paramtype region: str + :keyword instance: The particular VMSS instance from which to fire the request. + :paramtype instance: long + """ + super(ConnectivityCheckRequestSource, self).__init__(**kwargs) + self.region = region + self.instance = instance + + +class ConnectivityCheckResponse(msrest.serialization.Model): + """Information on the connectivity status. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar hops: List of hops between the source and the destination. + :vartype hops: list[~azure.mgmt.apimanagement.models.ConnectivityHop] + :ivar connection_status: The connection status. Possible values include: "Unknown", + "Connected", "Disconnected", "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 + :ivar min_latency_in_ms: Minimum latency in milliseconds. + :vartype min_latency_in_ms: long + :ivar max_latency_in_ms: Maximum latency in milliseconds. + :vartype max_latency_in_ms: long + :ivar probes_sent: Total number of probes sent. + :vartype probes_sent: long + :ivar probes_failed: Number of failed probes. + :vartype probes_failed: long + """ + + _validation = { + 'hops': {'readonly': True}, + 'connection_status': {'readonly': True}, + 'avg_latency_in_ms': {'readonly': True}, + 'min_latency_in_ms': {'readonly': True}, + 'max_latency_in_ms': {'readonly': True}, + 'probes_sent': {'readonly': True}, + 'probes_failed': {'readonly': True}, + } + + _attribute_map = { + 'hops': {'key': 'hops', 'type': '[ConnectivityHop]'}, + 'connection_status': {'key': 'connectionStatus', 'type': 'str'}, + 'avg_latency_in_ms': {'key': 'avgLatencyInMs', 'type': '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'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ConnectivityCheckResponse, self).__init__(**kwargs) + self.hops = None + self.connection_status = None + self.avg_latency_in_ms = None + self.min_latency_in_ms = None + self.max_latency_in_ms = None + self.probes_sent = None + self.probes_failed = None + + +class ConnectivityHop(msrest.serialization.Model): + """Information about a hop between the source and the destination. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The type of the hop. + :vartype type: str + :ivar id: The ID of the hop. + :vartype id: str + :ivar address: The IP address of the hop. + :vartype address: str + :ivar resource_id: The ID of the resource corresponding to this hop. + :vartype resource_id: str + :ivar next_hop_ids: List of next hop identifiers. + :vartype next_hop_ids: list[str] + :ivar issues: List of issues. + :vartype issues: list[~azure.mgmt.apimanagement.models.ConnectivityIssue] + """ + + _validation = { + 'type': {'readonly': True}, + 'id': {'readonly': True}, + 'address': {'readonly': True}, + 'resource_id': {'readonly': True}, + 'next_hop_ids': {'readonly': True}, + 'issues': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'address': {'key': 'address', 'type': 'str'}, + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + 'next_hop_ids': {'key': 'nextHopIds', 'type': '[str]'}, + 'issues': {'key': 'issues', 'type': '[ConnectivityIssue]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ConnectivityHop, self).__init__(**kwargs) + self.type = None + self.id = None + self.address = None + self.resource_id = None + self.next_hop_ids = None + self.issues = None + + +class ConnectivityIssue(msrest.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 ~azure.mgmt.apimanagement.models.Origin + :ivar severity: The severity of the issue. Possible values include: "Error", "Warning". + :vartype severity: str or ~azure.mgmt.apimanagement.models.Severity + :ivar type: The type of issue. Possible values include: "Unknown", "AgentStopped", + "GuestFirewall", "DnsResolution", "SocketBind", "NetworkSecurityRule", "UserDefinedRoute", + "PortThrottled", "Platform". + :vartype type: str or ~azure.mgmt.apimanagement.models.IssueType + :ivar context: Provides additional context on the issue. + :vartype context: list[dict[str, str]] + """ + + _validation = { + 'origin': {'readonly': True}, + 'severity': {'readonly': True}, + 'type': {'readonly': True}, + 'context': {'readonly': True}, + } + + _attribute_map = { + 'origin': {'key': 'origin', 'type': 'str'}, + 'severity': {'key': 'severity', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'context': {'key': 'context', 'type': '[{str}]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ConnectivityIssue, self).__init__(**kwargs) + self.origin = None + self.severity = None + self.type = None + self.context = None + + +class ConnectivityStatusContract(msrest.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. + :vartype name: str + :ivar status: Required. Resource Connectivity Status Type identifier. Possible values include: + "initializing", "success", "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 + Network.The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the + ISO 8601 standard. + :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. + :vartype last_status_change: ~datetime.datetime + :ivar resource_type: Required. Resource Type. + :vartype resource_type: str + :ivar is_optional: Required. Whether this is optional. + :vartype is_optional: bool + """ + + _validation = { + 'name': {'required': True, 'min_length': 1}, + 'status': {'required': True}, + 'last_updated': {'required': True}, + 'last_status_change': {'required': True}, + 'resource_type': {'required': True}, + 'is_optional': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'str'}, + 'last_updated': {'key': 'lastUpdated', 'type': 'iso-8601'}, + 'last_status_change': {'key': 'lastStatusChange', 'type': 'iso-8601'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'is_optional': {'key': 'isOptional', 'type': 'bool'}, + } + + def __init__( + self, + *, + name: str, + status: Union[str, "ConnectivityStatusType"], + last_updated: datetime.datetime, + last_status_change: datetime.datetime, + resource_type: str, + is_optional: bool, + error: Optional[str] = None, + **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. + :paramtype name: str + :keyword status: Required. Resource Connectivity Status Type identifier. Possible values + include: "initializing", "success", "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. + :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. + :paramtype last_status_change: ~datetime.datetime + :keyword resource_type: Required. Resource Type. + :paramtype resource_type: str + :keyword is_optional: Required. Whether this is optional. + :paramtype is_optional: bool + """ + super(ConnectivityStatusContract, self).__init__(**kwargs) + self.name = name + self.status = status + self.error = error + self.last_updated = last_updated + self.last_status_change = last_status_change + self.resource_type = resource_type + self.is_optional = is_optional + + +class ContentItemCollection(msrest.serialization.Model): + """Paged list of content items. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Collection of content items. + :vartype value: list[~azure.mgmt.apimanagement.models.ContentItemContract] + :ivar next_link: Next page link, if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ContentItemContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ContentItemCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ContentItemContract(Resource): + """Content type contract details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param properties: Properties of the content item. - :type properties: dict[str, any] + :ivar properties: Properties of the content item. + :vartype properties: dict[str, any] """ _validation = { @@ -5489,6 +8020,10 @@ def __init__( properties: Optional[Dict[str, Any]] = None, **kwargs ): + """ + :keyword properties: Properties of the content item. + :paramtype properties: dict[str, any] + """ super(ContentItemContract, self).__init__(**kwargs) self.properties = properties @@ -5518,6 +8053,8 @@ def __init__( self, **kwargs ): + """ + """ super(ContentTypeCollection, self).__init__(**kwargs) self.value = None self.next_link = None @@ -5528,22 +8065,24 @@ class ContentTypeContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param id_properties_id: Content type identifier. - :type id_properties_id: str - :param name_properties_name: Content type name. Must be 1 to 250 characters long. - :type name_properties_name: str - :param description: Content type description. - :type description: str - :param schema: Content type schema. - :type schema: any - :param version: Content type version. - :type version: str + :ivar id_properties_id: Content type identifier. + :vartype id_properties_id: str + :ivar name_properties_name: Content type name. Must be 1 to 250 characters long. + :vartype name_properties_name: str + :ivar description: Content type description. + :vartype description: str + :ivar schema: Content type schema. + :vartype schema: any + :ivar version: Content type version. + :vartype version: str """ _validation = { @@ -5573,6 +8112,18 @@ def __init__( version: Optional[str] = None, **kwargs ): + """ + :keyword id_properties_id: Content type identifier. + :paramtype id_properties_id: str + :keyword name_properties_name: Content type name. Must be 1 to 250 characters long. + :paramtype name_properties_name: str + :keyword description: Content type description. + :paramtype description: str + :keyword schema: Content type schema. + :paramtype schema: any + :keyword version: Content type version. + :paramtype version: str + """ super(ContentTypeContract, self).__init__(**kwargs) self.id_properties_id = id_properties_id self.name_properties_name = name_properties_name @@ -5584,10 +8135,10 @@ def __init__( class DataMasking(msrest.serialization.Model): """DataMasking. - :param query_params: Masking settings for Url query parameters. - :type query_params: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] - :param headers: Masking settings for headers. - :type headers: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] + :ivar query_params: Masking settings for Url query parameters. + :vartype query_params: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] + :ivar headers: Masking settings for headers. + :vartype headers: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] """ _attribute_map = { @@ -5602,6 +8153,12 @@ def __init__( headers: Optional[List["DataMaskingEntity"]] = None, **kwargs ): + """ + :keyword query_params: Masking settings for Url query parameters. + :paramtype query_params: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] + :keyword headers: Masking settings for headers. + :paramtype headers: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] + """ super(DataMasking, self).__init__(**kwargs) self.query_params = query_params self.headers = headers @@ -5610,10 +8167,10 @@ def __init__( class DataMaskingEntity(msrest.serialization.Model): """DataMaskingEntity. - :param value: The name of an entity to mask (e.g. a name of a header or a query parameter). - :type value: str - :param mode: Data masking mode. Possible values include: "Mask", "Hide". - :type mode: str or ~azure.mgmt.apimanagement.models.DataMaskingMode + :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 ~azure.mgmt.apimanagement.models.DataMaskingMode """ _attribute_map = { @@ -5628,33 +8185,41 @@ def __init__( mode: Optional[Union[str, "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 ~azure.mgmt.apimanagement.models.DataMaskingMode + """ super(DataMaskingEntity, self).__init__(**kwargs) self.value = value self.mode = mode class DeletedServiceContract(Resource): - """Deleted Api Management Service information. + """Deleted API Management Service information. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Api Management Service Master Location. + :ivar location: API Management Service Master Location. :vartype location: str - :param service_id: Fully-qualified API Management Service Resource ID. - :type service_id: str - :param scheduled_purge_date: UTC Date and Time when the service will be automatically purged. + :ivar service_id: Fully-qualified API Management Service Resource ID. + :vartype service_id: str + :ivar scheduled_purge_date: UTC Date and Time when the service will be automatically purged. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. - :type scheduled_purge_date: ~datetime.datetime - :param deletion_date: UTC Timestamp when the service was soft-deleted. The date conforms to the + :vartype scheduled_purge_date: ~datetime.datetime + :ivar deletion_date: UTC Timestamp when the service was soft-deleted. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. - :type deletion_date: ~datetime.datetime + :vartype deletion_date: ~datetime.datetime """ _validation = { @@ -5682,6 +8247,17 @@ def __init__( deletion_date: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword service_id: Fully-qualified API Management Service Resource ID. + :paramtype service_id: str + :keyword scheduled_purge_date: UTC Date and Time when the service will be automatically purged. + The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 + standard. + :paramtype scheduled_purge_date: ~datetime.datetime + :keyword deletion_date: UTC Timestamp when the service was soft-deleted. The date conforms to + the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :paramtype deletion_date: ~datetime.datetime + """ super(DeletedServiceContract, self).__init__(**kwargs) self.location = None self.service_id = service_id @@ -5690,7 +8266,7 @@ def __init__( class DeletedServicesCollection(msrest.serialization.Model): - """Paged deleted Api Management Services List Representation. + """Paged deleted API Management Services List Representation. Variables are only populated by the server, and will be ignored when sending a request. @@ -5714,6 +8290,8 @@ def __init__( self, **kwargs ): + """ + """ super(DeletedServicesCollection, self).__init__(**kwargs) self.value = None self.next_link = None @@ -5722,12 +8300,12 @@ def __init__( class DeployConfigurationParameters(msrest.serialization.Model): """Deploy Tenant Configuration Contract. - :param branch: The name of the Git branch from which the configuration is to be deployed to the + :ivar branch: The name of the Git branch from which the configuration is to be deployed to the configuration database. - :type branch: str - :param force: The value enforcing deleting subscriptions to products that are deleted in this + :vartype branch: str + :ivar force: The value enforcing deleting subscriptions to products that are deleted in this update. - :type force: bool + :vartype force: bool """ _attribute_map = { @@ -5742,6 +8320,14 @@ def __init__( 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. + :paramtype branch: str + :keyword force: The value enforcing deleting subscriptions to products that are deleted in this + update. + :paramtype force: bool + """ super(DeployConfigurationParameters, self).__init__(**kwargs) self.branch = branch self.force = force @@ -5750,12 +8336,12 @@ def __init__( class DiagnosticCollection(msrest.serialization.Model): """Paged Diagnostic list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.DiagnosticContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.DiagnosticContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -5772,6 +8358,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.DiagnosticContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(DiagnosticCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -5783,35 +8377,37 @@ class DiagnosticContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param always_log: Specifies for what type of messages sampling settings should not apply. + :ivar always_log: Specifies for what type of messages sampling settings should not apply. Possible values include: "allErrors". - :type always_log: str or ~azure.mgmt.apimanagement.models.AlwaysLog - :param logger_id: Resource Id of a target logger. - :type logger_id: str - :param sampling: Sampling settings for Diagnostic. - :type sampling: ~azure.mgmt.apimanagement.models.SamplingSettings - :param frontend: Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. - :type frontend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings - :param backend: Diagnostic settings for incoming/outgoing HTTP messages to the Backend. - :type backend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings - :param log_client_ip: Log the ClientIP. Default is false. - :type log_client_ip: bool - :param http_correlation_protocol: Sets correlation protocol to use for Application Insights + :vartype always_log: str or ~azure.mgmt.apimanagement.models.AlwaysLog + :ivar logger_id: Resource Id of a target logger. + :vartype logger_id: str + :ivar sampling: Sampling settings for Diagnostic. + :vartype sampling: ~azure.mgmt.apimanagement.models.SamplingSettings + :ivar frontend: Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. + :vartype frontend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings + :ivar backend: Diagnostic settings for incoming/outgoing HTTP messages to the Backend. + :vartype backend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings + :ivar log_client_ip: Log the ClientIP. Default is false. + :vartype log_client_ip: bool + :ivar http_correlation_protocol: Sets correlation protocol to use for Application Insights diagnostics. Possible values include: "None", "Legacy", "W3C". - :type http_correlation_protocol: str or + :vartype http_correlation_protocol: str or ~azure.mgmt.apimanagement.models.HttpCorrelationProtocol - :param verbosity: The verbosity level applied to traces emitted by trace policies. Possible + :ivar verbosity: The verbosity level applied to traces emitted by trace policies. Possible values include: "verbose", "information", "error". - :type verbosity: str or ~azure.mgmt.apimanagement.models.Verbosity - :param operation_name_format: The format of the Operation Name for Application Insights + :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". - :type operation_name_format: str or ~azure.mgmt.apimanagement.models.OperationNameFormat + :vartype operation_name_format: str or ~azure.mgmt.apimanagement.models.OperationNameFormat """ _validation = { @@ -5849,6 +8445,31 @@ def __init__( operation_name_format: Optional[Union[str, "OperationNameFormat"]] = 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 ~azure.mgmt.apimanagement.models.AlwaysLog + :keyword logger_id: Resource Id of a target logger. + :paramtype logger_id: str + :keyword sampling: Sampling settings for Diagnostic. + :paramtype sampling: ~azure.mgmt.apimanagement.models.SamplingSettings + :keyword frontend: Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. + :paramtype frontend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings + :keyword backend: Diagnostic settings for incoming/outgoing HTTP messages to the Backend. + :paramtype backend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings + :keyword log_client_ip: Log the ClientIP. Default is false. + :paramtype log_client_ip: bool + :keyword http_correlation_protocol: Sets correlation protocol to use for Application Insights + diagnostics. Possible values include: "None", "Legacy", "W3C". + :paramtype http_correlation_protocol: str or + ~azure.mgmt.apimanagement.models.HttpCorrelationProtocol + :keyword verbosity: The verbosity level applied to traces emitted by trace policies. Possible + values include: "verbose", "information", "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 ~azure.mgmt.apimanagement.models.OperationNameFormat + """ super(DiagnosticContract, self).__init__(**kwargs) self.always_log = always_log self.logger_id = logger_id @@ -5864,12 +8485,12 @@ def __init__( class EmailTemplateCollection(msrest.serialization.Model): """Paged email template list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.EmailTemplateContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.EmailTemplateContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -5886,6 +8507,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.EmailTemplateContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(EmailTemplateCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -5897,25 +8526,27 @@ class EmailTemplateContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param subject: Subject of the Template. - :type subject: str - :param body: Email Template Body. This should be a valid XDocument. - :type body: str - :param title: Title of the Template. - :type title: str - :param description: Description of the Email Template. - :type description: str - :ivar is_default: Whether the template is the default template provided by Api Management or + :ivar subject: Subject of the Template. + :vartype subject: str + :ivar body: Email Template Body. This should be a valid XDocument. + :vartype body: str + :ivar title: Title of the Template. + :vartype title: str + :ivar description: Description of the Email Template. + :vartype description: str + :ivar is_default: Whether the template is the default template provided by API Management or has been edited. :vartype is_default: bool - :param parameters: Email Template Parameter values. - :type parameters: + :ivar parameters: Email Template Parameter values. + :vartype parameters: list[~azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties] """ @@ -5950,6 +8581,19 @@ def __init__( parameters: Optional[List["EmailTemplateParametersContractProperties"]] = None, **kwargs ): + """ + :keyword subject: Subject of the Template. + :paramtype subject: str + :keyword body: Email Template Body. This should be a valid XDocument. + :paramtype body: str + :keyword title: Title of the Template. + :paramtype title: str + :keyword description: Description of the Email Template. + :paramtype description: str + :keyword parameters: Email Template Parameter values. + :paramtype parameters: + list[~azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties] + """ super(EmailTemplateContract, self).__init__(**kwargs) self.subject = subject self.body = body @@ -5962,12 +8606,12 @@ def __init__( class EmailTemplateParametersContractProperties(msrest.serialization.Model): """Email Template Parameter contract. - :param name: Template parameter name. - :type name: str - :param title: Template parameter title. - :type title: str - :param description: Template parameter description. - :type description: str + :ivar name: Template parameter name. + :vartype name: str + :ivar title: Template parameter title. + :vartype title: str + :ivar description: Template parameter description. + :vartype description: str """ _validation = { @@ -5990,6 +8634,14 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword name: Template parameter name. + :paramtype name: str + :keyword title: Template parameter title. + :paramtype title: str + :keyword description: Template parameter description. + :paramtype description: str + """ super(EmailTemplateParametersContractProperties, self).__init__(**kwargs) self.name = name self.title = title @@ -5999,16 +8651,16 @@ def __init__( class EmailTemplateUpdateParameters(msrest.serialization.Model): """Email Template update Parameters. - :param subject: Subject of the Template. - :type subject: str - :param title: Title of the Template. - :type title: str - :param description: Description of the Email Template. - :type description: str - :param body: Email Template Body. This should be a valid XDocument. - :type body: str - :param parameters: Email Template Parameter values. - :type parameters: + :ivar subject: Subject of the Template. + :vartype subject: str + :ivar title: Title of the Template. + :vartype title: str + :ivar description: Description of the Email Template. + :vartype description: str + :ivar body: Email Template Body. This should be a valid XDocument. + :vartype body: str + :ivar parameters: Email Template Parameter values. + :vartype parameters: list[~azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties] """ @@ -6035,6 +8687,19 @@ def __init__( parameters: Optional[List["EmailTemplateParametersContractProperties"]] = None, **kwargs ): + """ + :keyword subject: Subject of the Template. + :paramtype subject: str + :keyword title: Title of the Template. + :paramtype title: str + :keyword description: Description of the Email Template. + :paramtype description: str + :keyword body: Email Template Body. This should be a valid XDocument. + :paramtype body: str + :keyword parameters: Email Template Parameter values. + :paramtype parameters: + list[~azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties] + """ super(EmailTemplateUpdateParameters, self).__init__(**kwargs) self.subject = subject self.title = title @@ -6043,15 +8708,79 @@ def __init__( self.parameters = parameters +class EndpointDependency(msrest.serialization.Model): + """A domain name that a service is reached at. + + :ivar domain_name: The domain name of the dependency. + :vartype domain_name: str + :ivar endpoint_details: The Ports used when connecting to DomainName. + :vartype endpoint_details: list[~azure.mgmt.apimanagement.models.EndpointDetail] + """ + + _attribute_map = { + 'domain_name': {'key': 'domainName', 'type': 'str'}, + 'endpoint_details': {'key': 'endpointDetails', 'type': '[EndpointDetail]'}, + } + + def __init__( + self, + *, + domain_name: Optional[str] = None, + endpoint_details: Optional[List["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[~azure.mgmt.apimanagement.models.EndpointDetail] + """ + super(EndpointDependency, self).__init__(**kwargs) + self.domain_name = domain_name + self.endpoint_details = endpoint_details + + +class EndpointDetail(msrest.serialization.Model): + """Current TCP connectivity information from the Api Management Service to a single endpoint. + + :ivar port: The port an endpoint is connected to. + :vartype port: int + :ivar region: The region of the dependency. + :vartype region: str + """ + + _attribute_map = { + 'port': {'key': 'port', 'type': 'int'}, + 'region': {'key': 'region', 'type': 'str'}, + } + + def __init__( + self, + *, + port: Optional[int] = None, + region: Optional[str] = None, + **kwargs + ): + """ + :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) + self.port = port + self.region = region + + class ErrorFieldContract(msrest.serialization.Model): """Error Field contract. - :param code: Property level error code. - :type code: str - :param message: Human-readable representation of property-level error. - :type message: str - :param target: Property name. - :type target: str + :ivar code: Property level error code. + :vartype code: str + :ivar message: Human-readable representation of property-level error. + :vartype message: str + :ivar target: Property name. + :vartype target: str """ _attribute_map = { @@ -6068,6 +8797,14 @@ def __init__( target: Optional[str] = None, **kwargs ): + """ + :keyword code: Property level error code. + :paramtype code: str + :keyword message: Human-readable representation of property-level error. + :paramtype message: str + :keyword target: Property name. + :paramtype target: str + """ super(ErrorFieldContract, self).__init__(**kwargs) self.code = code self.message = message @@ -6077,13 +8814,13 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error Response. - :param code: Service-defined error code. This code serves as a sub-status for the HTTP error + :ivar code: Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. - :type code: str - :param message: Human-readable representation of the error. - :type message: str - :param details: The list of invalid fields send in request, in case of validation error. - :type details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] + :vartype code: str + :ivar message: Human-readable representation of the error. + :vartype message: str + :ivar details: The list of invalid fields send in request, in case of validation error. + :vartype details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] """ _attribute_map = { @@ -6100,6 +8837,15 @@ def __init__( details: Optional[List["ErrorFieldContract"]] = None, **kwargs ): + """ + :keyword code: Service-defined error code. This code serves as a sub-status for the HTTP error + code specified in the response. + :paramtype code: str + :keyword message: Human-readable representation of the error. + :paramtype message: str + :keyword details: The list of invalid fields send in request, in case of validation error. + :paramtype details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -6109,13 +8855,13 @@ def __init__( class ErrorResponseBody(msrest.serialization.Model): """Error Body contract. - :param code: Service-defined error code. This code serves as a sub-status for the HTTP error + :ivar code: Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. - :type code: str - :param message: Human-readable representation of the error. - :type message: str - :param details: The list of invalid fields send in request, in case of validation error. - :type details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] + :vartype code: str + :ivar message: Human-readable representation of the error. + :vartype message: str + :ivar details: The list of invalid fields send in request, in case of validation error. + :vartype details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] """ _attribute_map = { @@ -6132,6 +8878,15 @@ def __init__( details: Optional[List["ErrorFieldContract"]] = None, **kwargs ): + """ + :keyword code: Service-defined error code. This code serves as a sub-status for the HTTP error + code specified in the response. + :paramtype code: str + :keyword message: Human-readable representation of the error. + :paramtype message: str + :keyword details: The list of invalid fields send in request, in case of validation error. + :paramtype details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] + """ super(ErrorResponseBody, self).__init__(**kwargs) self.code = code self.message = message @@ -6163,6 +8918,8 @@ def __init__( self, **kwargs ): + """ + """ super(GatewayCertificateAuthorityCollection, self).__init__(**kwargs) self.value = None self.next_link = None @@ -6173,14 +8930,16 @@ class GatewayCertificateAuthorityContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param is_trusted: Determines whether certificate authority is trusted. - :type is_trusted: bool + :ivar is_trusted: Determines whether certificate authority is trusted. + :vartype is_trusted: bool """ _validation = { @@ -6202,6 +8961,10 @@ def __init__( is_trusted: Optional[bool] = None, **kwargs ): + """ + :keyword is_trusted: Determines whether certificate authority is trusted. + :paramtype is_trusted: bool + """ super(GatewayCertificateAuthorityContract, self).__init__(**kwargs) self.is_trusted = is_trusted @@ -6213,8 +8976,8 @@ class GatewayCollection(msrest.serialization.Model): :ivar value: Page values. :vartype value: list[~azure.mgmt.apimanagement.models.GatewayContract] - :param count: Total record count number across all pages. - :type count: long + :ivar count: Total record count number across all pages. + :vartype count: long :ivar next_link: Next page link if any. :vartype next_link: str """ @@ -6236,6 +8999,10 @@ def __init__( count: Optional[int] = None, **kwargs ): + """ + :keyword count: Total record count number across all pages. + :paramtype count: long + """ super(GatewayCollection, self).__init__(**kwargs) self.value = None self.count = count @@ -6247,16 +9014,18 @@ class GatewayContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param location_data: Gateway location. - :type location_data: ~azure.mgmt.apimanagement.models.ResourceLocationDataContract - :param description: Gateway description. - :type description: str + :ivar location_data: Gateway location. + :vartype location_data: ~azure.mgmt.apimanagement.models.ResourceLocationDataContract + :ivar description: Gateway description. + :vartype description: str """ _validation = { @@ -6281,6 +9050,12 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword location_data: Gateway location. + :paramtype location_data: ~azure.mgmt.apimanagement.models.ResourceLocationDataContract + :keyword description: Gateway description. + :paramtype description: str + """ super(GatewayContract, self).__init__(**kwargs) self.location_data = location_data self.description = description @@ -6311,6 +9086,8 @@ def __init__( self, **kwargs ): + """ + """ super(GatewayHostnameConfigurationCollection, self).__init__(**kwargs) self.value = None self.next_link = None @@ -6321,25 +9098,27 @@ class GatewayHostnameConfigurationContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param hostname: Hostname value. Supports valid domain name, partial or full wildcard. - :type hostname: str - :param certificate_id: Identifier of Certificate entity that will be used for TLS connection + :ivar hostname: Hostname value. Supports valid domain name, partial or full wildcard. + :vartype hostname: str + :ivar certificate_id: Identifier of Certificate entity that will be used for TLS connection establishment. - :type certificate_id: str - :param negotiate_client_certificate: Determines whether gateway requests client certificate. - :type negotiate_client_certificate: bool - :param tls10_enabled: Specifies if TLS 1.0 is supported. - :type tls10_enabled: bool - :param tls11_enabled: Specifies if TLS 1.1 is supported. - :type tls11_enabled: bool - :param http2_enabled: Specifies if HTTP/2.0 is supported. - :type http2_enabled: bool + :vartype certificate_id: str + :ivar negotiate_client_certificate: Determines whether gateway requests client certificate. + :vartype negotiate_client_certificate: bool + :ivar tls10_enabled: Specifies if TLS 1.0 is supported. + :vartype tls10_enabled: bool + :ivar tls11_enabled: Specifies if TLS 1.1 is supported. + :vartype tls11_enabled: bool + :ivar http2_enabled: Specifies if HTTP/2.0 is supported. + :vartype http2_enabled: bool """ _validation = { @@ -6371,6 +9150,21 @@ def __init__( http2_enabled: Optional[bool] = None, **kwargs ): + """ + :keyword hostname: Hostname value. Supports valid domain name, partial or full wildcard. + :paramtype hostname: str + :keyword certificate_id: Identifier of Certificate entity that will be used for TLS connection + establishment. + :paramtype certificate_id: str + :keyword negotiate_client_certificate: Determines whether gateway requests client certificate. + :paramtype negotiate_client_certificate: bool + :keyword tls10_enabled: Specifies if TLS 1.0 is supported. + :paramtype tls10_enabled: bool + :keyword tls11_enabled: Specifies if TLS 1.1 is supported. + :paramtype tls11_enabled: bool + :keyword http2_enabled: Specifies if HTTP/2.0 is supported. + :paramtype http2_enabled: bool + """ super(GatewayHostnameConfigurationContract, self).__init__(**kwargs) self.hostname = hostname self.certificate_id = certificate_id @@ -6385,9 +9179,9 @@ class GatewayKeyRegenerationRequestContract(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_type: Required. The Key being regenerated. Possible values include: "primary", + :ivar key_type: Required. The Key being regenerated. Possible values include: "primary", "secondary". - :type key_type: str or ~azure.mgmt.apimanagement.models.KeyType + :vartype key_type: str or ~azure.mgmt.apimanagement.models.KeyType """ _validation = { @@ -6404,6 +9198,11 @@ def __init__( key_type: Union[str, "KeyType"], **kwargs ): + """ + :keyword key_type: Required. The Key being regenerated. Possible values include: "primary", + "secondary". + :paramtype key_type: str or ~azure.mgmt.apimanagement.models.KeyType + """ super(GatewayKeyRegenerationRequestContract, self).__init__(**kwargs) self.key_type = key_type @@ -6411,10 +9210,10 @@ def __init__( class GatewayKeysContract(msrest.serialization.Model): """Gateway authentication keys. - :param primary: Primary gateway key. - :type primary: str - :param secondary: Secondary gateway key. - :type secondary: str + :ivar primary: Primary gateway key. + :vartype primary: str + :ivar secondary: Secondary gateway key. + :vartype secondary: str """ _attribute_map = { @@ -6429,6 +9228,12 @@ def __init__( 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) self.primary = primary self.secondary = secondary @@ -6437,8 +9242,8 @@ def __init__( class GatewayTokenContract(msrest.serialization.Model): """Gateway access token. - :param value: Shared Access Authentication token value for the Gateway. - :type value: str + :ivar value: Shared Access Authentication token value for the Gateway. + :vartype value: str """ _attribute_map = { @@ -6451,6 +9256,10 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword value: Shared Access Authentication token value for the Gateway. + :paramtype value: str + """ super(GatewayTokenContract, self).__init__(**kwargs) self.value = value @@ -6460,13 +9269,13 @@ class GatewayTokenRequestContract(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_type: Required. The Key to be used to generate gateway token. Possible values + :ivar key_type: Required. The Key to be used to generate gateway token. Possible values include: "primary", "secondary". - :type key_type: str or ~azure.mgmt.apimanagement.models.KeyType - :param expiry: Required. The Expiry time of the Token. Maximum token expiry time is set to 30 + :vartype key_type: str or ~azure.mgmt.apimanagement.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. - :type expiry: ~datetime.datetime + :vartype expiry: ~datetime.datetime """ _validation = { @@ -6486,6 +9295,15 @@ def __init__( 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 ~azure.mgmt.apimanagement.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. + :paramtype expiry: ~datetime.datetime + """ super(GatewayTokenRequestContract, self).__init__(**kwargs) self.key_type = key_type self.expiry = expiry @@ -6494,8 +9312,8 @@ def __init__( class GenerateSsoUrlResult(msrest.serialization.Model): """Generate SSO Url operations response details. - :param value: Redirect Url containing the SSO URL value. - :type value: str + :ivar value: Redirect Url containing the SSO URL value. + :vartype value: str """ _attribute_map = { @@ -6508,19 +9326,129 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword value: Redirect Url containing the SSO URL value. + :paramtype value: str + """ super(GenerateSsoUrlResult, self).__init__(**kwargs) self.value = value +class GlobalSchemaCollection(msrest.serialization.Model): + """The response of the list schema operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Global Schema Contract value. + :vartype value: list[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :ivar count: Total record count number. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GlobalSchemaContract]'}, + 'count': {'key': 'count', 'type': 'long'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + count: Optional[int] = None, + **kwargs + ): + """ + :keyword count: Total record count number. + :paramtype count: long + """ + super(GlobalSchemaCollection, self).__init__(**kwargs) + self.value = None + self.count = count + self.next_link = None + + +class GlobalSchemaContract(Resource): + """Global Schema Contract details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar schema_type: Schema Type. Immutable. Possible values include: "xml", "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 + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + '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, + description: Optional[str] = None, + value: Optional[Any] = None, + document: Optional[Any] = None, + **kwargs + ): + """ + :keyword schema_type: Schema Type. Immutable. Possible values include: "xml", "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 + """ + super(GlobalSchemaContract, self).__init__(**kwargs) + self.schema_type = schema_type + self.description = description + self.value = value + self.document = document + + class GroupCollection(msrest.serialization.Model): """Paged Group list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.GroupContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.GroupContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -6537,6 +9465,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.GroupContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(GroupCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -6548,26 +9484,28 @@ class GroupContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param display_name: Group name. - :type display_name: str - :param description: Group description. Can contain HTML formatting tags. - :type description: str + :ivar display_name: Group name. + :vartype display_name: str + :ivar description: Group description. Can contain HTML formatting tags. + :vartype description: str :ivar built_in: true if the group is one of the three system groups (Administrators, Developers, or Guests); otherwise false. :vartype built_in: bool - :param type_properties_type: Group type. Possible values include: "custom", "system", + :ivar type_properties_type: Group type. Possible values include: "custom", "system", "external". - :type type_properties_type: str or ~azure.mgmt.apimanagement.models.GroupType - :param external_id: For external groups, this property contains the id of the group from the + :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. - :type external_id: str + :vartype external_id: str """ _validation = { @@ -6599,6 +9537,19 @@ def __init__( external_id: Optional[str] = None, **kwargs ): + """ + :keyword display_name: Group name. + :paramtype display_name: str + :keyword description: Group description. Can contain HTML formatting tags. + :paramtype description: str + :keyword type_properties_type: Group type. Possible values include: "custom", "system", + "external". + :paramtype type_properties_type: str or ~azure.mgmt.apimanagement.models.GroupType + :keyword external_id: For external groups, this property contains the id of the group from the + external identity provider, e.g. for Azure Active Directory + ``aad://.onmicrosoft.com/groups/``\ ; otherwise the value is null. + :paramtype external_id: str + """ super(GroupContract, self).__init__(**kwargs) self.display_name = display_name self.description = description @@ -6614,19 +9565,19 @@ class GroupContractProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param display_name: Required. Group name. - :type display_name: str - :param description: Group description. Can contain HTML formatting tags. - :type description: str + :ivar display_name: Required. Group name. + :vartype display_name: str + :ivar description: Group description. Can contain HTML formatting tags. + :vartype description: str :ivar built_in: true if the group is one of the three system groups (Administrators, Developers, or Guests); otherwise false. :vartype built_in: bool - :param type: Group type. Possible values include: "custom", "system", "external". - :type type: str or ~azure.mgmt.apimanagement.models.GroupType - :param external_id: For external groups, this property contains the id of the group from the + :ivar type: Group type. Possible values include: "custom", "system", "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. - :type external_id: str + :vartype external_id: str """ _validation = { @@ -6652,6 +9603,18 @@ def __init__( external_id: Optional[str] = None, **kwargs ): + """ + :keyword display_name: Required. Group name. + :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 ~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) self.display_name = display_name self.description = description @@ -6663,16 +9626,16 @@ def __init__( class GroupCreateParameters(msrest.serialization.Model): """Parameters supplied to the Create Group operation. - :param display_name: Group name. - :type display_name: str - :param description: Group description. - :type description: str - :param type: Group type. Possible values include: "custom", "system", "external". - :type type: str or ~azure.mgmt.apimanagement.models.GroupType - :param external_id: Identifier of the external groups, this property contains the id of the + :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 ~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. - :type external_id: str + :vartype external_id: str """ _validation = { @@ -6695,6 +9658,18 @@ def __init__( external_id: Optional[str] = None, **kwargs ): + """ + :keyword display_name: Group name. + :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 ~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) self.display_name = display_name self.description = description @@ -6705,16 +9680,16 @@ def __init__( class GroupUpdateParameters(msrest.serialization.Model): """Parameters supplied to the Update Group operation. - :param display_name: Group name. - :type display_name: str - :param description: Group description. - :type description: str - :param type: Group type. Possible values include: "custom", "system", "external". - :type type: str or ~azure.mgmt.apimanagement.models.GroupType - :param external_id: Identifier of the external groups, this property contains the id of the + :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 ~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. - :type external_id: str + :vartype external_id: str """ _validation = { @@ -6737,6 +9712,18 @@ def __init__( external_id: Optional[str] = None, **kwargs ): + """ + :keyword display_name: Group name. + :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 ~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) self.display_name = display_name self.description = description @@ -6749,34 +9736,40 @@ class HostnameConfiguration(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. Hostname type. Possible values include: "Proxy", "Portal", "Management", + :ivar type: Required. Hostname type. Possible values include: "Proxy", "Portal", "Management", "Scm", "DeveloperPortal". - :type type: str or ~azure.mgmt.apimanagement.models.HostnameType - :param host_name: Required. Hostname to configure on the Api Management service. - :type host_name: str - :param key_vault_id: Url to the KeyVault Secret containing the Ssl Certificate. If absolute Url + :vartype type: str or ~azure.mgmt.apimanagement.models.HostnameType + :ivar host_name: Required. Hostname to configure on the Api Management service. + :vartype host_name: str + :ivar key_vault_id: Url to the KeyVault Secret containing the Ssl Certificate. If absolute Url containing version is provided, auto-update of ssl certificate will not work. This requires Api Management service to be configured with aka.ms/apimmsi. The secret should be of type *application/x-pkcs12*. - :type key_vault_id: str - :param identity_client_id: System or User Assigned Managed identity clientId as generated by + :vartype key_vault_id: str + :ivar identity_client_id: System or User Assigned Managed identity clientId as generated by Azure AD, which has GET access to the keyVault containing the SSL certificate. - :type identity_client_id: str - :param encoded_certificate: Base64 Encoded certificate. - :type encoded_certificate: str - :param certificate_password: Certificate Password. - :type certificate_password: str - :param default_ssl_binding: Specify true to setup the certificate associated with this Hostname + :vartype identity_client_id: str + :ivar encoded_certificate: Base64 Encoded certificate. + :vartype encoded_certificate: str + :ivar certificate_password: Certificate Password. + :vartype certificate_password: str + :ivar default_ssl_binding: Specify true to setup the certificate associated with this Hostname as the Default SSL Certificate. If a client does not send the SNI header, then this will be the certificate that will be challenged. The property is useful if a service has multiple custom hostname enabled and it needs to decide on the default ssl certificate. The setting only applied to Proxy Hostname Type. - :type default_ssl_binding: bool - :param negotiate_client_certificate: Specify true to always negotiate client certificate on the + :vartype default_ssl_binding: bool + :ivar negotiate_client_certificate: Specify true to always negotiate client certificate on the hostname. Default Value is false. - :type negotiate_client_certificate: bool - :param certificate: Certificate information. - :type certificate: ~azure.mgmt.apimanagement.models.CertificateInformation + :vartype negotiate_client_certificate: bool + :ivar certificate: Certificate information. + :vartype certificate: ~azure.mgmt.apimanagement.models.CertificateInformation + :ivar certificate_source: Certificate Source. Possible values include: "Managed", "KeyVault", + "Custom", "BuiltIn". + :vartype certificate_source: str or ~azure.mgmt.apimanagement.models.CertificateSource + :ivar certificate_status: Certificate Status. Possible values include: "Completed", "Failed", + "InProgress". + :vartype certificate_status: str or ~azure.mgmt.apimanagement.models.CertificateStatus """ _validation = { @@ -6794,6 +9787,8 @@ class HostnameConfiguration(msrest.serialization.Model): '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__( @@ -6808,8 +9803,46 @@ def __init__( default_ssl_binding: Optional[bool] = False, negotiate_client_certificate: Optional[bool] = False, certificate: Optional["CertificateInformation"] = None, - **kwargs - ): + certificate_source: Optional[Union[str, "CertificateSource"]] = None, + certificate_status: Optional[Union[str, "CertificateStatus"]] = None, + **kwargs + ): + """ + :keyword type: Required. Hostname type. Possible values include: "Proxy", "Portal", + "Management", "Scm", "DeveloperPortal". + :paramtype type: str or ~azure.mgmt.apimanagement.models.HostnameType + :keyword host_name: Required. Hostname to configure on the Api Management service. + :paramtype host_name: str + :keyword key_vault_id: Url to the KeyVault Secret containing the Ssl Certificate. If absolute + Url containing version is provided, auto-update of ssl certificate will not work. This requires + Api Management service to be configured with aka.ms/apimmsi. The secret should be of type + *application/x-pkcs12*. + :paramtype key_vault_id: str + :keyword identity_client_id: System or User Assigned Managed identity clientId as generated by + Azure AD, which has GET access to the keyVault containing the SSL certificate. + :paramtype identity_client_id: str + :keyword encoded_certificate: Base64 Encoded certificate. + :paramtype encoded_certificate: str + :keyword certificate_password: Certificate Password. + :paramtype certificate_password: str + :keyword default_ssl_binding: Specify true to setup the certificate associated with this + Hostname as the Default SSL Certificate. If a client does not send the SNI header, then this + will be the certificate that will be challenged. The property is useful if a service has + multiple custom hostname enabled and it needs to decide on the default ssl certificate. The + setting only applied to Proxy Hostname Type. + :paramtype default_ssl_binding: bool + :keyword negotiate_client_certificate: Specify true to always negotiate client certificate on + the hostname. Default Value is false. + :paramtype negotiate_client_certificate: bool + :keyword certificate: Certificate information. + :paramtype certificate: ~azure.mgmt.apimanagement.models.CertificateInformation + :keyword certificate_source: Certificate Source. Possible values include: "Managed", + "KeyVault", "Custom", "BuiltIn". + :paramtype certificate_source: str or ~azure.mgmt.apimanagement.models.CertificateSource + :keyword certificate_status: Certificate Status. Possible values include: "Completed", + "Failed", "InProgress". + :paramtype certificate_status: str or ~azure.mgmt.apimanagement.models.CertificateStatus + """ super(HostnameConfiguration, self).__init__(**kwargs) self.type = type self.host_name = host_name @@ -6820,17 +9853,58 @@ def __init__( self.default_ssl_binding = default_ssl_binding self.negotiate_client_certificate = negotiate_client_certificate self.certificate = certificate + self.certificate_source = certificate_source + self.certificate_status = certificate_status + + +class HTTPHeader(msrest.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. + :vartype name: str + :ivar value: Required. Header value. + :vartype value: str + """ + + _validation = { + 'name': {'required': True}, + 'value': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + value: str, + **kwargs + ): + """ + :keyword name: Required. Header name. + :paramtype name: str + :keyword value: Required. Header value. + :paramtype value: str + """ + super(HTTPHeader, self).__init__(**kwargs) + self.name = name + self.value = value class HttpMessageDiagnostic(msrest.serialization.Model): """Http message diagnostic settings. - :param headers: Array of HTTP Headers to log. - :type headers: list[str] - :param body: Body logging settings. - :type body: ~azure.mgmt.apimanagement.models.BodyDiagnosticSettings - :param data_masking: Data masking settings. - :type data_masking: ~azure.mgmt.apimanagement.models.DataMasking + :ivar headers: Array of HTTP Headers to log. + :vartype headers: list[str] + :ivar body: Body logging settings. + :vartype body: ~azure.mgmt.apimanagement.models.BodyDiagnosticSettings + :ivar data_masking: Data masking settings. + :vartype data_masking: ~azure.mgmt.apimanagement.models.DataMasking """ _attribute_map = { @@ -6847,6 +9921,14 @@ def __init__( data_masking: Optional["DataMasking"] = None, **kwargs ): + """ + :keyword headers: Array of HTTP Headers to log. + :paramtype headers: list[str] + :keyword body: Body logging settings. + :paramtype body: ~azure.mgmt.apimanagement.models.BodyDiagnosticSettings + :keyword data_masking: Data masking settings. + :paramtype data_masking: ~azure.mgmt.apimanagement.models.DataMasking + """ super(HttpMessageDiagnostic, self).__init__(**kwargs) self.headers = headers self.body = body @@ -6856,25 +9938,25 @@ def __init__( class IdentityProviderBaseParameters(msrest.serialization.Model): """Identity Provider Base Parameter Properties. - :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", + :ivar type: Identity Provider Type identifier. Possible values include: "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + :vartype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. + :vartype signin_tenant: str + :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. + :vartype allowed_tenants: list[str] + :ivar authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :vartype authority: str + :ivar signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signup_policy_name: str + :ivar signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signin_policy_name: str + :ivar profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C Identity Provider. - :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + :vartype profile_editing_policy_name: str + :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. - :type password_reset_policy_name: str + :vartype password_reset_policy_name: str """ _validation = { @@ -6909,6 +9991,29 @@ def __init__( password_reset_policy_name: Optional[str] = None, **kwargs ): + """ + :keyword type: Identity Provider Type identifier. Possible values include: "facebook", + "google", "microsoft", "twitter", "aad", "aadB2C". + :paramtype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :keyword signin_tenant: The TenantId to use instead of Common when logging into Active + Directory. + :paramtype signin_tenant: str + :keyword allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory + login. + :paramtype allowed_tenants: list[str] + :keyword authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :paramtype authority: str + :keyword signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :paramtype signup_policy_name: str + :keyword signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :paramtype signin_policy_name: str + :keyword profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. + :paramtype profile_editing_policy_name: str + :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C + Identity Provider. + :paramtype password_reset_policy_name: str + """ super(IdentityProviderBaseParameters, self).__init__(**kwargs) self.type = type self.signin_tenant = signin_tenant @@ -6925,39 +10030,41 @@ class IdentityProviderContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param type_properties_type: Identity Provider Type identifier. Possible values include: + :ivar type_properties_type: Identity Provider Type identifier. Possible values include: "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :type type_properties_type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + :vartype type_properties_type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. + :vartype signin_tenant: str + :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. + :vartype allowed_tenants: list[str] + :ivar authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :vartype authority: str + :ivar signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signup_policy_name: str + :ivar signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signin_policy_name: str + :ivar profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C Identity Provider. - :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + :vartype profile_editing_policy_name: str + :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. - :type password_reset_policy_name: str - :param client_id: Client Id of the Application in the external Identity Provider. It is App ID + :vartype password_reset_policy_name: str + :ivar client_id: Client Id of the Application in the external Identity Provider. It is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. - :type client_id: str - :param client_secret: Client secret of the Application in external Identity Provider, used to + :vartype client_id: str + :ivar client_secret: Client secret of the Application in external Identity Provider, used to authenticate login request. For example, it is App Secret for Facebook login, API Key for Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. - :type client_secret: str + :vartype client_secret: str """ _validation = { @@ -7004,6 +10111,37 @@ def __init__( client_secret: Optional[str] = None, **kwargs ): + """ + :keyword type_properties_type: Identity Provider Type identifier. Possible values include: + "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". + :paramtype type_properties_type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :keyword signin_tenant: The TenantId to use instead of Common when logging into Active + Directory. + :paramtype signin_tenant: str + :keyword allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory + login. + :paramtype allowed_tenants: list[str] + :keyword authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :paramtype authority: str + :keyword signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :paramtype signup_policy_name: str + :keyword signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :paramtype signin_policy_name: str + :keyword profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. + :paramtype profile_editing_policy_name: str + :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C + Identity Provider. + :paramtype password_reset_policy_name: str + :keyword client_id: Client Id of the Application in the external Identity Provider. It is App + ID for Facebook login, Client ID for Google login, App ID for Microsoft. + :paramtype client_id: str + :keyword client_secret: Client secret of the Application in external Identity Provider, used to + authenticate login request. For example, it is App Secret for Facebook login, API Key for + Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! + Use '/listSecrets' POST request to get the value. + :paramtype client_secret: str + """ super(IdentityProviderContract, self).__init__(**kwargs) self.type_properties_type = type_properties_type self.signin_tenant = signin_tenant @@ -7022,33 +10160,33 @@ class IdentityProviderContractProperties(IdentityProviderBaseParameters): All required parameters must be populated in order to send to Azure. - :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", + :ivar type: Identity Provider Type identifier. Possible values include: "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + :vartype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. + :vartype signin_tenant: str + :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. + :vartype allowed_tenants: list[str] + :ivar authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :vartype authority: str + :ivar signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signup_policy_name: str + :ivar signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signin_policy_name: str + :ivar profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C Identity Provider. - :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + :vartype profile_editing_policy_name: str + :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. - :type password_reset_policy_name: str - :param client_id: Required. Client Id of the Application in the external Identity Provider. It + :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. - :type client_id: str - :param client_secret: Client secret of the Application in external Identity Provider, used to + :vartype client_id: str + :ivar client_secret: Client secret of the Application in external Identity Provider, used to authenticate login request. For example, it is App Secret for Facebook login, API Key for Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. - :type client_secret: str + :vartype client_secret: str """ _validation = { @@ -7089,6 +10227,37 @@ def __init__( client_secret: Optional[str] = None, **kwargs ): + """ + :keyword type: Identity Provider Type identifier. Possible values include: "facebook", + "google", "microsoft", "twitter", "aad", "aadB2C". + :paramtype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :keyword signin_tenant: The TenantId to use instead of Common when logging into Active + Directory. + :paramtype signin_tenant: str + :keyword allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory + login. + :paramtype allowed_tenants: list[str] + :keyword authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :paramtype authority: str + :keyword signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :paramtype signup_policy_name: str + :keyword signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :paramtype signin_policy_name: str + :keyword profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. + :paramtype profile_editing_policy_name: str + :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C + Identity Provider. + :paramtype password_reset_policy_name: str + :keyword client_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. + :paramtype client_id: str + :keyword client_secret: Client secret of the Application in external Identity Provider, used to + authenticate login request. For example, it is App Secret for Facebook login, API Key for + Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! + Use '/listSecrets' POST request to get the value. + :paramtype client_secret: str + """ super(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) self.client_id = client_id self.client_secret = client_secret @@ -7099,39 +10268,41 @@ class IdentityProviderCreateContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param type_properties_type: Identity Provider Type identifier. Possible values include: + :ivar type_properties_type: Identity Provider Type identifier. Possible values include: "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :type type_properties_type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + :vartype type_properties_type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. + :vartype signin_tenant: str + :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. + :vartype allowed_tenants: list[str] + :ivar authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :vartype authority: str + :ivar signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signup_policy_name: str + :ivar signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signin_policy_name: str + :ivar profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C Identity Provider. - :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + :vartype profile_editing_policy_name: str + :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. - :type password_reset_policy_name: str - :param client_id: Client Id of the Application in the external Identity Provider. It is App ID + :vartype password_reset_policy_name: str + :ivar client_id: Client Id of the Application in the external Identity Provider. It is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. - :type client_id: str - :param client_secret: Client secret of the Application in external Identity Provider, used to + :vartype client_id: str + :ivar client_secret: Client secret of the Application in external Identity Provider, used to authenticate login request. For example, it is App Secret for Facebook login, API Key for Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. - :type client_secret: str + :vartype client_secret: str """ _validation = { @@ -7178,6 +10349,37 @@ def __init__( client_secret: Optional[str] = None, **kwargs ): + """ + :keyword type_properties_type: Identity Provider Type identifier. Possible values include: + "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". + :paramtype type_properties_type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :keyword signin_tenant: The TenantId to use instead of Common when logging into Active + Directory. + :paramtype signin_tenant: str + :keyword allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory + login. + :paramtype allowed_tenants: list[str] + :keyword authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :paramtype authority: str + :keyword signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :paramtype signup_policy_name: str + :keyword signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :paramtype signin_policy_name: str + :keyword profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. + :paramtype profile_editing_policy_name: str + :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C + Identity Provider. + :paramtype password_reset_policy_name: str + :keyword client_id: Client Id of the Application in the external Identity Provider. It is App + ID for Facebook login, Client ID for Google login, App ID for Microsoft. + :paramtype client_id: str + :keyword client_secret: Client secret of the Application in external Identity Provider, used to + authenticate login request. For example, it is App Secret for Facebook login, API Key for + Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! + Use '/listSecrets' POST request to get the value. + :paramtype client_secret: str + """ super(IdentityProviderCreateContract, self).__init__(**kwargs) self.type_properties_type = type_properties_type self.signin_tenant = signin_tenant @@ -7196,33 +10398,33 @@ class IdentityProviderCreateContractProperties(IdentityProviderBaseParameters): All required parameters must be populated in order to send to Azure. - :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", + :ivar type: Identity Provider Type identifier. Possible values include: "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + :vartype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. + :vartype signin_tenant: str + :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. + :vartype allowed_tenants: list[str] + :ivar authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :vartype authority: str + :ivar signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signup_policy_name: str + :ivar signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signin_policy_name: str + :ivar profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C Identity Provider. - :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + :vartype profile_editing_policy_name: str + :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. - :type password_reset_policy_name: str - :param client_id: Required. Client Id of the Application in the external Identity Provider. It + :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. - :type client_id: str - :param client_secret: Required. Client secret of the Application in external Identity Provider, + :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. - :type client_secret: str + :vartype client_secret: str """ _validation = { @@ -7263,6 +10465,37 @@ def __init__( password_reset_policy_name: Optional[str] = None, **kwargs ): + """ + :keyword type: Identity Provider Type identifier. Possible values include: "facebook", + "google", "microsoft", "twitter", "aad", "aadB2C". + :paramtype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :keyword signin_tenant: The TenantId to use instead of Common when logging into Active + Directory. + :paramtype signin_tenant: str + :keyword allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory + login. + :paramtype allowed_tenants: list[str] + :keyword authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :paramtype authority: str + :keyword signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :paramtype signup_policy_name: str + :keyword signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :paramtype signin_policy_name: str + :keyword profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. + :paramtype profile_editing_policy_name: str + :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C + Identity Provider. + :paramtype password_reset_policy_name: str + :keyword client_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. + :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. + :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) self.client_id = client_id self.client_secret = client_secret @@ -7271,12 +10504,12 @@ def __init__( class IdentityProviderList(msrest.serialization.Model): """List of all the Identity Providers configured on the service instance. - :param value: Identity Provider configuration values. - :type value: list[~azure.mgmt.apimanagement.models.IdentityProviderContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Identity Provider configuration values. + :vartype value: list[~azure.mgmt.apimanagement.models.IdentityProviderContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -7293,6 +10526,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Identity Provider configuration values. + :paramtype value: list[~azure.mgmt.apimanagement.models.IdentityProviderContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(IdentityProviderList, self).__init__(**kwargs) self.value = value self.count = count @@ -7302,32 +10543,32 @@ def __init__( class IdentityProviderUpdateParameters(msrest.serialization.Model): """Parameters supplied to update Identity Provider. - :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", + :ivar type: Identity Provider Type identifier. Possible values include: "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + :vartype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. + :vartype signin_tenant: str + :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. + :vartype allowed_tenants: list[str] + :ivar authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :vartype authority: str + :ivar signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signup_policy_name: str + :ivar signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signin_policy_name: str + :ivar profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C Identity Provider. - :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + :vartype profile_editing_policy_name: str + :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. - :type password_reset_policy_name: str - :param client_id: Client Id of the Application in the external Identity Provider. It is App ID + :vartype password_reset_policy_name: str + :ivar client_id: Client Id of the Application in the external Identity Provider. It is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. - :type client_id: str - :param client_secret: Client secret of the Application in external Identity Provider, used to + :vartype client_id: str + :ivar client_secret: Client secret of the Application in external Identity Provider, used to authenticate login request. For example, it is App Secret for Facebook login, API Key for Google login, Public Key for Microsoft. - :type client_secret: str + :vartype client_secret: str """ _validation = { @@ -7368,6 +10609,36 @@ def __init__( client_secret: Optional[str] = None, **kwargs ): + """ + :keyword type: Identity Provider Type identifier. Possible values include: "facebook", + "google", "microsoft", "twitter", "aad", "aadB2C". + :paramtype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :keyword signin_tenant: The TenantId to use instead of Common when logging into Active + Directory. + :paramtype signin_tenant: str + :keyword allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory + login. + :paramtype allowed_tenants: list[str] + :keyword authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :paramtype authority: str + :keyword signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :paramtype signup_policy_name: str + :keyword signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :paramtype signin_policy_name: str + :keyword profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. + :paramtype profile_editing_policy_name: str + :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C + Identity Provider. + :paramtype password_reset_policy_name: str + :keyword client_id: Client Id of the Application in the external Identity Provider. It is App + ID for Facebook login, Client ID for Google login, App ID for Microsoft. + :paramtype client_id: str + :keyword client_secret: Client secret of the Application in external Identity Provider, used to + authenticate login request. For example, it is App Secret for Facebook login, API Key for + Google login, Public Key for Microsoft. + :paramtype client_secret: str + """ super(IdentityProviderUpdateParameters, self).__init__(**kwargs) self.type = type self.signin_tenant = signin_tenant @@ -7384,32 +10655,32 @@ def __init__( class IdentityProviderUpdateProperties(IdentityProviderBaseParameters): """Parameters supplied to the Update Identity Provider operation. - :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", + :ivar type: Identity Provider Type identifier. Possible values include: "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + :vartype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. + :vartype signin_tenant: str + :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. + :vartype allowed_tenants: list[str] + :ivar authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :vartype authority: str + :ivar signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signup_policy_name: str + :ivar signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signin_policy_name: str + :ivar profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C Identity Provider. - :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + :vartype profile_editing_policy_name: str + :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. - :type password_reset_policy_name: str - :param client_id: Client Id of the Application in the external Identity Provider. It is App ID + :vartype password_reset_policy_name: str + :ivar client_id: Client Id of the Application in the external Identity Provider. It is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. - :type client_id: str - :param client_secret: Client secret of the Application in external Identity Provider, used to + :vartype client_id: str + :ivar client_secret: Client secret of the Application in external Identity Provider, used to authenticate login request. For example, it is App Secret for Facebook login, API Key for Google login, Public Key for Microsoft. - :type client_secret: str + :vartype client_secret: str """ _validation = { @@ -7450,6 +10721,36 @@ def __init__( client_secret: Optional[str] = None, **kwargs ): + """ + :keyword type: Identity Provider Type identifier. Possible values include: "facebook", + "google", "microsoft", "twitter", "aad", "aadB2C". + :paramtype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :keyword signin_tenant: The TenantId to use instead of Common when logging into Active + Directory. + :paramtype signin_tenant: str + :keyword allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory + login. + :paramtype allowed_tenants: list[str] + :keyword authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :paramtype authority: str + :keyword signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :paramtype signup_policy_name: str + :keyword signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :paramtype signin_policy_name: str + :keyword profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. + :paramtype profile_editing_policy_name: str + :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C + Identity Provider. + :paramtype password_reset_policy_name: str + :keyword client_id: Client Id of the Application in the external Identity Provider. It is App + ID for Facebook login, Client ID for Google login, App ID for Microsoft. + :paramtype client_id: str + :keyword client_secret: Client secret of the Application in external Identity Provider, used to + authenticate login request. For example, it is App Secret for Facebook login, API Key for + Google login, Public Key for Microsoft. + :paramtype client_secret: str + """ super(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) self.client_id = client_id self.client_secret = client_secret @@ -7462,8 +10763,8 @@ class IssueAttachmentCollection(msrest.serialization.Model): :ivar value: Issue Attachment values. :vartype value: list[~azure.mgmt.apimanagement.models.IssueAttachmentContract] - :param count: Total record count number across all pages. - :type count: long + :ivar count: Total record count number across all pages. + :vartype count: long :ivar next_link: Next page link if any. :vartype next_link: str """ @@ -7485,6 +10786,10 @@ def __init__( count: Optional[int] = None, **kwargs ): + """ + :keyword count: Total record count number across all pages. + :paramtype count: long + """ super(IssueAttachmentCollection, self).__init__(**kwargs) self.value = None self.count = count @@ -7496,19 +10801,21 @@ class IssueAttachmentContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param title: Filename by which the binary data will be saved. - :type title: str - :param content_format: Either 'link' if content is provided via an HTTP link or the MIME type - of the Base64-encoded binary data provided in the 'content' property. - :type content_format: str - :param content: An HTTP link or Base64-encoded binary data. - :type content: str + :ivar title: Filename by which the binary data will be saved. + :vartype title: str + :ivar content_format: Either 'link' if content is provided via an HTTP link or the MIME type of + the Base64-encoded binary data provided in the 'content' property. + :vartype content_format: str + :ivar content: An HTTP link or Base64-encoded binary data. + :vartype content: str """ _validation = { @@ -7534,6 +10841,15 @@ def __init__( content: Optional[str] = None, **kwargs ): + """ + :keyword title: Filename by which the binary data will be saved. + :paramtype title: str + :keyword content_format: Either 'link' if content is provided via an HTTP link or the MIME type + of the Base64-encoded binary data provided in the 'content' property. + :paramtype content_format: str + :keyword content: An HTTP link or Base64-encoded binary data. + :paramtype content: str + """ super(IssueAttachmentContract, self).__init__(**kwargs) self.title = title self.content_format = content_format @@ -7547,8 +10863,8 @@ class IssueCollection(msrest.serialization.Model): :ivar value: Issue values. :vartype value: list[~azure.mgmt.apimanagement.models.IssueContract] - :param count: Total record count number across all pages. - :type count: long + :ivar count: Total record count number across all pages. + :vartype count: long :ivar next_link: Next page link if any. :vartype next_link: str """ @@ -7570,6 +10886,10 @@ def __init__( count: Optional[int] = None, **kwargs ): + """ + :keyword count: Total record count number across all pages. + :paramtype count: long + """ super(IssueCollection, self).__init__(**kwargs) self.value = None self.count = count @@ -7583,8 +10903,8 @@ class IssueCommentCollection(msrest.serialization.Model): :ivar value: Issue Comment values. :vartype value: list[~azure.mgmt.apimanagement.models.IssueCommentContract] - :param count: Total record count number across all pages. - :type count: long + :ivar count: Total record count number across all pages. + :vartype count: long :ivar next_link: Next page link if any. :vartype next_link: str """ @@ -7606,6 +10926,10 @@ def __init__( count: Optional[int] = None, **kwargs ): + """ + :keyword count: Total record count number across all pages. + :paramtype count: long + """ super(IssueCommentCollection, self).__init__(**kwargs) self.value = None self.count = count @@ -7617,18 +10941,20 @@ class IssueCommentContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param text: Comment text. - :type text: str - :param created_date: Date and time when the comment was created. - :type created_date: ~datetime.datetime - :param user_id: A resource identifier for the user who left the comment. - :type user_id: str + :ivar text: Comment text. + :vartype text: str + :ivar created_date: Date and time when the comment was created. + :vartype created_date: ~datetime.datetime + :ivar user_id: A resource identifier for the user who left the comment. + :vartype user_id: str """ _validation = { @@ -7654,6 +10980,14 @@ def __init__( user_id: Optional[str] = None, **kwargs ): + """ + :keyword text: Comment text. + :paramtype text: str + :keyword created_date: Date and time when the comment was created. + :paramtype created_date: ~datetime.datetime + :keyword user_id: A resource identifier for the user who left the comment. + :paramtype user_id: str + """ super(IssueCommentContract, self).__init__(**kwargs) self.text = text self.created_date = created_date @@ -7665,25 +10999,27 @@ class IssueContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param created_date: Date and time when the issue was created. - :type created_date: ~datetime.datetime - :param state: Status of the issue. Possible values include: "proposed", "open", "removed", + :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". - :type state: str or ~azure.mgmt.apimanagement.models.State - :param api_id: A resource identifier for the API the issue was created for. - :type api_id: str - :param title: The issue title. - :type title: str - :param description: Text describing the issue. - :type description: str - :param user_id: A resource identifier for the user created the issue. - :type user_id: str + :vartype state: str or ~azure.mgmt.apimanagement.models.State + :ivar api_id: A resource identifier for the API the issue was created for. + :vartype api_id: str + :ivar title: The issue title. + :vartype title: str + :ivar description: Text describing the issue. + :vartype description: str + :ivar user_id: A resource identifier for the user created the issue. + :vartype user_id: str """ _validation = { @@ -7715,6 +11051,21 @@ def __init__( user_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 ~azure.mgmt.apimanagement.models.State + :keyword api_id: A resource identifier for the API the issue was created for. + :paramtype api_id: str + :keyword title: The issue title. + :paramtype title: str + :keyword description: Text describing the issue. + :paramtype description: str + :keyword user_id: A resource identifier for the user created the issue. + :paramtype user_id: str + """ super(IssueContract, self).__init__(**kwargs) self.created_date = created_date self.state = state @@ -7727,13 +11078,13 @@ def __init__( class IssueContractBaseProperties(msrest.serialization.Model): """Issue contract Base Properties. - :param created_date: Date and time when the issue was created. - :type created_date: ~datetime.datetime - :param state: Status of the issue. Possible values include: "proposed", "open", "removed", + :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". - :type state: str or ~azure.mgmt.apimanagement.models.State - :param api_id: A resource identifier for the API the issue was created for. - :type api_id: str + :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 = { @@ -7750,6 +11101,15 @@ def __init__( 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 ~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) self.created_date = created_date self.state = state @@ -7761,19 +11121,19 @@ class IssueContractProperties(IssueContractBaseProperties): All required parameters must be populated in order to send to Azure. - :param created_date: Date and time when the issue was created. - :type created_date: ~datetime.datetime - :param state: Status of the issue. Possible values include: "proposed", "open", "removed", + :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". - :type state: str or ~azure.mgmt.apimanagement.models.State - :param api_id: A resource identifier for the API the issue was created for. - :type api_id: str - :param title: Required. The issue title. - :type title: str - :param description: Required. Text describing the issue. - :type description: str - :param user_id: Required. A resource identifier for the user created the issue. - :type user_id: str + :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. + :vartype title: str + :ivar description: Required. Text describing the issue. + :vartype description: str + :ivar user_id: Required. A resource identifier for the user created the issue. + :vartype user_id: str """ _validation = { @@ -7802,6 +11162,21 @@ def __init__( 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 ~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. + :paramtype title: str + :keyword description: Required. Text describing the issue. + :paramtype description: str + :keyword user_id: Required. A resource identifier for the user created the issue. + :paramtype user_id: str + """ super(IssueContractProperties, self).__init__(created_date=created_date, state=state, api_id=api_id, **kwargs) self.title = title self.description = description @@ -7811,19 +11186,19 @@ def __init__( class IssueUpdateContract(msrest.serialization.Model): """Issue update Parameters. - :param created_date: Date and time when the issue was created. - :type created_date: ~datetime.datetime - :param state: Status of the issue. Possible values include: "proposed", "open", "removed", + :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". - :type state: str or ~azure.mgmt.apimanagement.models.State - :param api_id: A resource identifier for the API the issue was created for. - :type api_id: str - :param title: The issue title. - :type title: str - :param description: Text describing the issue. - :type description: str - :param user_id: A resource identifier for the user created the issue. - :type user_id: str + :vartype state: str or ~azure.mgmt.apimanagement.models.State + :ivar api_id: A resource identifier for the API the issue was created for. + :vartype api_id: str + :ivar title: The issue title. + :vartype title: str + :ivar description: Text describing the issue. + :vartype description: str + :ivar user_id: A resource identifier for the user created the issue. + :vartype user_id: str """ _attribute_map = { @@ -7846,6 +11221,21 @@ def __init__( user_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 ~azure.mgmt.apimanagement.models.State + :keyword api_id: A resource identifier for the API the issue was created for. + :paramtype api_id: str + :keyword title: The issue title. + :paramtype title: str + :keyword description: Text describing the issue. + :paramtype description: str + :keyword user_id: A resource identifier for the user created the issue. + :paramtype user_id: str + """ super(IssueUpdateContract, self).__init__(**kwargs) self.created_date = created_date self.state = state @@ -7858,19 +11248,19 @@ def __init__( class IssueUpdateContractProperties(IssueContractBaseProperties): """Issue contract Update Properties. - :param created_date: Date and time when the issue was created. - :type created_date: ~datetime.datetime - :param state: Status of the issue. Possible values include: "proposed", "open", "removed", + :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". - :type state: str or ~azure.mgmt.apimanagement.models.State - :param api_id: A resource identifier for the API the issue was created for. - :type api_id: str - :param title: The issue title. - :type title: str - :param description: Text describing the issue. - :type description: str - :param user_id: A resource identifier for the user created the issue. - :type user_id: str + :vartype state: str or ~azure.mgmt.apimanagement.models.State + :ivar api_id: A resource identifier for the API the issue was created for. + :vartype api_id: str + :ivar title: The issue title. + :vartype title: str + :ivar description: Text describing the issue. + :vartype description: str + :ivar user_id: A resource identifier for the user created the issue. + :vartype user_id: str """ _attribute_map = { @@ -7893,6 +11283,21 @@ def __init__( user_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 ~azure.mgmt.apimanagement.models.State + :keyword api_id: A resource identifier for the API the issue was created for. + :paramtype api_id: str + :keyword title: The issue title. + :paramtype title: str + :keyword description: Text describing the issue. + :paramtype description: str + :keyword user_id: A resource identifier for the user created the issue. + :paramtype user_id: str + """ super(IssueUpdateContractProperties, self).__init__(created_date=created_date, state=state, api_id=api_id, **kwargs) self.title = title self.description = description @@ -7902,13 +11307,13 @@ def __init__( class KeyVaultContractCreateProperties(msrest.serialization.Model): """Create keyVault contract details. - :param 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. - :type secret_identifier: str - :param identity_client_id: SystemAssignedIdentity or UserAssignedIdentity Client Id which will + :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. - :type identity_client_id: str + :vartype identity_client_id: str """ _attribute_map = { @@ -7923,6 +11328,15 @@ def __init__( 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. + :paramtype identity_client_id: str + """ super(KeyVaultContractCreateProperties, self).__init__(**kwargs) self.secret_identifier = secret_identifier self.identity_client_id = identity_client_id @@ -7931,15 +11345,16 @@ def __init__( class KeyVaultContractProperties(KeyVaultContractCreateProperties): """KeyVault contract details. - :param 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. - :type secret_identifier: str - :param identity_client_id: SystemAssignedIdentity or UserAssignedIdentity Client Id which will + :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. - :type identity_client_id: str - :param last_status: Last time sync and refresh status of secret from key vault. - :type last_status: ~azure.mgmt.apimanagement.models.KeyVaultLastAccessStatusContractProperties + :vartype identity_client_id: str + :ivar last_status: Last time sync and refresh status of secret from key vault. + :vartype last_status: + ~azure.mgmt.apimanagement.models.KeyVaultLastAccessStatusContractProperties """ _attribute_map = { @@ -7956,6 +11371,18 @@ def __init__( last_status: Optional["KeyVaultLastAccessStatusContractProperties"] = 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. + :paramtype identity_client_id: str + :keyword last_status: Last time sync and refresh status of secret from key vault. + :paramtype last_status: + ~azure.mgmt.apimanagement.models.KeyVaultLastAccessStatusContractProperties + """ super(KeyVaultContractProperties, self).__init__(secret_identifier=secret_identifier, identity_client_id=identity_client_id, **kwargs) self.last_status = last_status @@ -7963,13 +11390,13 @@ def __init__( class KeyVaultLastAccessStatusContractProperties(msrest.serialization.Model): """Issue contract Update Properties. - :param code: Last status code for sync and refresh of secret from key vault. - :type code: str - :param message: Details of the error else empty. - :type message: str - :param time_stamp_utc: Last time secret was accessed. The date conforms to the following - format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type time_stamp_utc: ~datetime.datetime + :ivar code: Last status code for sync and refresh of secret from key vault. + :vartype code: str + :ivar message: Details of the error else empty. + :vartype message: str + :ivar time_stamp_utc: Last time secret was accessed. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype time_stamp_utc: ~datetime.datetime """ _attribute_map = { @@ -7986,6 +11413,15 @@ def __init__( time_stamp_utc: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword code: Last status code for sync and refresh of secret from key vault. + :paramtype code: str + :keyword message: Details of the error else empty. + :paramtype message: str + :keyword time_stamp_utc: Last time secret was accessed. The date conforms to the following + format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :paramtype time_stamp_utc: ~datetime.datetime + """ super(KeyVaultLastAccessStatusContractProperties, self).__init__(**kwargs) self.code = code self.message = message @@ -7995,12 +11431,12 @@ def __init__( class LoggerCollection(msrest.serialization.Model): """Paged Logger list representation. - :param value: Logger values. - :type value: list[~azure.mgmt.apimanagement.models.LoggerContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Logger values. + :vartype value: list[~azure.mgmt.apimanagement.models.LoggerContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -8017,6 +11453,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Logger values. + :paramtype value: list[~azure.mgmt.apimanagement.models.LoggerContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(LoggerCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -8028,27 +11472,29 @@ class LoggerContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param logger_type: Logger type. Possible values include: "azureEventHub", + :ivar logger_type: Logger type. Possible values include: "azureEventHub", "applicationInsights", "azureMonitor". - :type logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType - :param description: Logger description. - :type description: str - :param credentials: The name and SendRule connection string of the event hub for azureEventHub + :vartype logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType + :ivar description: Logger description. + :vartype description: str + :ivar credentials: The name and SendRule connection string of the event hub for azureEventHub logger. Instrumentation key for applicationInsights logger. - :type credentials: dict[str, str] - :param is_buffered: Whether records are buffered in the logger before publishing. Default is + :vartype credentials: dict[str, str] + :ivar is_buffered: Whether records are buffered in the logger before publishing. Default is assumed to be true. - :type is_buffered: bool - :param resource_id: Azure Resource Id of a log target (either Azure Event Hub resource or Azure + :vartype is_buffered: bool + :ivar resource_id: Azure Resource Id of a log target (either Azure Event Hub resource or Azure Application Insights resource). - :type resource_id: str + :vartype resource_id: str """ _validation = { @@ -8079,6 +11525,23 @@ def __init__( resource_id: Optional[str] = None, **kwargs ): + """ + :keyword logger_type: Logger type. Possible values include: "azureEventHub", + "applicationInsights", "azureMonitor". + :paramtype logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType + :keyword description: Logger description. + :paramtype description: str + :keyword credentials: The name and SendRule connection string of the event hub for + azureEventHub logger. + Instrumentation key for applicationInsights logger. + :paramtype credentials: dict[str, str] + :keyword is_buffered: Whether records are buffered in the logger before publishing. Default is + assumed to be true. + :paramtype is_buffered: bool + :keyword resource_id: Azure Resource Id of a log target (either Azure Event Hub resource or + Azure Application Insights resource). + :paramtype resource_id: str + """ super(LoggerContract, self).__init__(**kwargs) self.logger_type = logger_type self.description = description @@ -8090,16 +11553,16 @@ def __init__( class LoggerUpdateContract(msrest.serialization.Model): """Logger update contract. - :param logger_type: Logger type. Possible values include: "azureEventHub", + :ivar logger_type: Logger type. Possible values include: "azureEventHub", "applicationInsights", "azureMonitor". - :type logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType - :param description: Logger description. - :type description: str - :param credentials: Logger credentials. - :type credentials: dict[str, str] - :param is_buffered: Whether records are buffered in the logger before publishing. Default is + :vartype logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType + :ivar description: Logger description. + :vartype description: str + :ivar credentials: Logger credentials. + :vartype credentials: dict[str, str] + :ivar is_buffered: Whether records are buffered in the logger before publishing. Default is assumed to be true. - :type is_buffered: bool + :vartype is_buffered: bool """ _attribute_map = { @@ -8118,6 +11581,18 @@ def __init__( is_buffered: Optional[bool] = None, **kwargs ): + """ + :keyword logger_type: Logger type. Possible values include: "azureEventHub", + "applicationInsights", "azureMonitor". + :paramtype logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType + :keyword description: Logger description. + :paramtype description: str + :keyword credentials: Logger credentials. + :paramtype credentials: dict[str, str] + :keyword is_buffered: Whether records are buffered in the logger before publishing. Default is + assumed to be true. + :paramtype is_buffered: bool + """ super(LoggerUpdateContract, self).__init__(**kwargs) self.logger_type = logger_type self.description = description @@ -8128,12 +11603,12 @@ def __init__( class NamedValueCollection(msrest.serialization.Model): """Paged NamedValue list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.NamedValueContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.NamedValueContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -8150,6 +11625,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.NamedValueContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(NamedValueCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -8161,27 +11644,29 @@ class NamedValueContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Optional tags that when provided can be used to filter the + :ivar tags: A set of tags. Optional tags that when provided can be used to filter the NamedValue list. - :type tags: list[str] - :param secret: Determines whether the value is a secret and should be encrypted or not. Default + :vartype tags: list[str] + :ivar secret: Determines whether the value is a secret and should be encrypted or not. Default value is false. - :type secret: bool - :param display_name: Unique name of NamedValue. It may contain only letters, digits, period, + :vartype secret: bool + :ivar display_name: Unique name of NamedValue. It may contain only letters, digits, period, dash, and underscore characters. - :type display_name: str - :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + :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. - :type value: str - :param key_vault: KeyVault location details of the namedValue. - :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties + :vartype value: str + :ivar key_vault: KeyVault location details of the namedValue. + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties """ _validation = { @@ -8214,6 +11699,23 @@ def __init__( key_vault: Optional["KeyVaultContractProperties"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Optional tags that when provided can be used to filter the + NamedValue list. + :paramtype tags: list[str] + :keyword secret: Determines whether the value is a secret and should be encrypted or not. + Default value is false. + :paramtype secret: bool + :keyword display_name: Unique name of NamedValue. It may contain only letters, digits, period, + dash, and underscore characters. + :paramtype display_name: str + :keyword value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. This property will not be filled on 'GET' operations! Use + '/listSecrets' POST request to get the value. + :paramtype value: str + :keyword key_vault: KeyVault location details of the namedValue. + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties + """ super(NamedValueContract, self).__init__(**kwargs) self.tags = tags self.secret = secret @@ -8225,12 +11727,12 @@ def __init__( class NamedValueEntityBaseParameters(msrest.serialization.Model): """NamedValue Entity Base Parameters set. - :param tags: A set of tags. Optional tags that when provided can be used to filter the + :ivar tags: A set of tags. Optional tags that when provided can be used to filter the NamedValue list. - :type tags: list[str] - :param secret: Determines whether the value is a secret and should be encrypted or not. Default + :vartype tags: list[str] + :ivar secret: Determines whether the value is a secret and should be encrypted or not. Default value is false. - :type secret: bool + :vartype secret: bool """ _validation = { @@ -8249,6 +11751,14 @@ def __init__( secret: Optional[bool] = None, **kwargs ): + """ + :keyword tags: A set of 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) self.tags = tags self.secret = secret @@ -8259,21 +11769,21 @@ class NamedValueContractProperties(NamedValueEntityBaseParameters): All required parameters must be populated in order to send to Azure. - :param tags: A set of tags. Optional tags that when provided can be used to filter the + :ivar tags: A set of tags. Optional tags that when provided can be used to filter the NamedValue list. - :type tags: list[str] - :param secret: Determines whether the value is a secret and should be encrypted or not. Default + :vartype tags: list[str] + :ivar secret: Determines whether the value is a secret and should be encrypted or not. Default value is false. - :type secret: bool - :param display_name: Required. Unique name of NamedValue. It may contain only letters, digits, + :vartype secret: bool + :ivar display_name: Required. Unique name of NamedValue. It may contain only letters, digits, period, dash, and underscore characters. - :type display_name: str - :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + :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. - :type value: str - :param key_vault: KeyVault location details of the namedValue. - :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties + :vartype value: str + :ivar key_vault: KeyVault location details of the namedValue. + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties """ _validation = { @@ -8300,6 +11810,23 @@ def __init__( key_vault: Optional["KeyVaultContractProperties"] = None, **kwargs ): + """ + :keyword tags: A set of 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. + :paramtype display_name: str + :keyword value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. This property will not be filled on 'GET' operations! Use + '/listSecrets' POST request to get the value. + :paramtype value: str + :keyword key_vault: KeyVault location details of the namedValue. + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties + """ super(NamedValueContractProperties, self).__init__(tags=tags, secret=secret, **kwargs) self.display_name = display_name self.value = value @@ -8311,27 +11838,29 @@ class NamedValueCreateContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Optional tags that when provided can be used to filter the + :ivar tags: A set of tags. Optional tags that when provided can be used to filter the NamedValue list. - :type tags: list[str] - :param secret: Determines whether the value is a secret and should be encrypted or not. Default + :vartype tags: list[str] + :ivar secret: Determines whether the value is a secret and should be encrypted or not. Default value is false. - :type secret: bool - :param display_name: Unique name of NamedValue. It may contain only letters, digits, period, + :vartype secret: bool + :ivar display_name: Unique name of NamedValue. It may contain only letters, digits, period, dash, and underscore characters. - :type display_name: str - :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + :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. - :type value: str - :param key_vault: KeyVault location details of the namedValue. - :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties + :vartype value: str + :ivar key_vault: KeyVault location details of the namedValue. + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ _validation = { @@ -8364,6 +11893,23 @@ def __init__( key_vault: Optional["KeyVaultContractCreateProperties"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Optional tags that when provided can be used to filter the + NamedValue list. + :paramtype tags: list[str] + :keyword secret: Determines whether the value is a secret and should be encrypted or not. + Default value is false. + :paramtype secret: bool + :keyword display_name: Unique name of NamedValue. It may contain only letters, digits, period, + dash, and underscore characters. + :paramtype display_name: str + :keyword value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. This property will not be filled on 'GET' operations! Use + '/listSecrets' POST request to get the value. + :paramtype value: str + :keyword key_vault: KeyVault location details of the namedValue. + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties + """ super(NamedValueCreateContract, self).__init__(**kwargs) self.tags = tags self.secret = secret @@ -8377,21 +11923,21 @@ class NamedValueCreateContractProperties(NamedValueEntityBaseParameters): All required parameters must be populated in order to send to Azure. - :param tags: A set of tags. Optional tags that when provided can be used to filter the + :ivar tags: A set of tags. Optional tags that when provided can be used to filter the NamedValue list. - :type tags: list[str] - :param secret: Determines whether the value is a secret and should be encrypted or not. Default + :vartype tags: list[str] + :ivar secret: Determines whether the value is a secret and should be encrypted or not. Default value is false. - :type secret: bool - :param display_name: Required. Unique name of NamedValue. It may contain only letters, digits, + :vartype secret: bool + :ivar display_name: Required. Unique name of NamedValue. It may contain only letters, digits, period, dash, and underscore characters. - :type display_name: str - :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + :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. - :type value: str - :param key_vault: KeyVault location details of the namedValue. - :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties + :vartype value: str + :ivar key_vault: KeyVault location details of the namedValue. + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ _validation = { @@ -8418,6 +11964,23 @@ def __init__( key_vault: Optional["KeyVaultContractCreateProperties"] = None, **kwargs ): + """ + :keyword tags: A set of 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. + :paramtype display_name: str + :keyword value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. This property will not be filled on 'GET' operations! Use + '/listSecrets' POST request to get the value. + :paramtype value: str + :keyword key_vault: KeyVault location details of the namedValue. + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties + """ super(NamedValueCreateContractProperties, self).__init__(tags=tags, secret=secret, **kwargs) self.display_name = display_name self.value = value @@ -8427,8 +11990,8 @@ def __init__( class NamedValueSecretContract(msrest.serialization.Model): """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. - :param value: This is secret value of the NamedValue entity. - :type value: str + :ivar value: This is secret value of the NamedValue entity. + :vartype value: str """ _attribute_map = { @@ -8441,6 +12004,10 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword value: This is secret value of the NamedValue entity. + :paramtype value: str + """ super(NamedValueSecretContract, self).__init__(**kwargs) self.value = value @@ -8448,20 +12015,20 @@ def __init__( class NamedValueUpdateParameterProperties(NamedValueEntityBaseParameters): """NamedValue Contract properties. - :param tags: A set of tags. Optional tags that when provided can be used to filter the + :ivar tags: A set of tags. Optional tags that when provided can be used to filter the NamedValue list. - :type tags: list[str] - :param secret: Determines whether the value is a secret and should be encrypted or not. Default + :vartype tags: list[str] + :ivar secret: Determines whether the value is a secret and should be encrypted or not. Default value is false. - :type secret: bool - :param display_name: Unique name of NamedValue. It may contain only letters, digits, period, + :vartype secret: bool + :ivar display_name: Unique name of NamedValue. It may contain only letters, digits, period, dash, and underscore characters. - :type display_name: str - :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + :vartype display_name: str + :ivar value: Value of the NamedValue. Can contain policy expressions. It may not be empty or consist only of whitespace. - :type value: str - :param key_vault: KeyVault location details of the namedValue. - :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties + :vartype value: str + :ivar key_vault: KeyVault location details of the namedValue. + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ _validation = { @@ -8488,6 +12055,22 @@ def __init__( key_vault: Optional["KeyVaultContractCreateProperties"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Optional tags that when provided can be used to filter the + NamedValue list. + :paramtype tags: list[str] + :keyword secret: Determines whether the value is a secret and should be encrypted or not. + Default value is false. + :paramtype secret: bool + :keyword display_name: Unique name of NamedValue. It may contain only letters, digits, period, + dash, and underscore characters. + :paramtype display_name: str + :keyword value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. + :paramtype value: str + :keyword key_vault: KeyVault location details of the namedValue. + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties + """ super(NamedValueUpdateParameterProperties, self).__init__(tags=tags, secret=secret, **kwargs) self.display_name = display_name self.value = value @@ -8497,20 +12080,20 @@ def __init__( class NamedValueUpdateParameters(msrest.serialization.Model): """NamedValue update Parameters. - :param tags: A set of tags. Optional tags that when provided can be used to filter the + :ivar tags: A set of tags. Optional tags that when provided can be used to filter the NamedValue list. - :type tags: list[str] - :param secret: Determines whether the value is a secret and should be encrypted or not. Default + :vartype tags: list[str] + :ivar secret: Determines whether the value is a secret and should be encrypted or not. Default value is false. - :type secret: bool - :param display_name: Unique name of NamedValue. It may contain only letters, digits, period, + :vartype secret: bool + :ivar display_name: Unique name of NamedValue. It may contain only letters, digits, period, dash, and underscore characters. - :type display_name: str - :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + :vartype display_name: str + :ivar value: Value of the NamedValue. Can contain policy expressions. It may not be empty or consist only of whitespace. - :type value: str - :param key_vault: KeyVault location details of the namedValue. - :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties + :vartype value: str + :ivar key_vault: KeyVault location details of the namedValue. + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ _validation = { @@ -8537,6 +12120,22 @@ def __init__( key_vault: Optional["KeyVaultContractCreateProperties"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Optional tags that when provided can be used to filter the + NamedValue list. + :paramtype tags: list[str] + :keyword secret: Determines whether the value is a secret and should be encrypted or not. + Default value is false. + :paramtype secret: bool + :keyword display_name: Unique name of NamedValue. It may contain only letters, digits, period, + dash, and underscore characters. + :paramtype display_name: str + :keyword value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. + :paramtype value: str + :keyword key_vault: KeyVault location details of the namedValue. + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties + """ super(NamedValueUpdateParameters, self).__init__(**kwargs) self.tags = tags self.secret = secret @@ -8550,11 +12149,11 @@ class NetworkStatusContract(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param dns_servers: Required. Gets the list of DNS servers IPV4 addresses. - :type dns_servers: list[str] - :param connectivity_status: Required. Gets the list of Connectivity Status to the Resources on + :ivar dns_servers: Required. Gets the list of DNS servers IPV4 addresses. + :vartype dns_servers: list[str] + :ivar connectivity_status: Required. Gets the list of Connectivity Status to the Resources on which the service depends upon. - :type connectivity_status: list[~azure.mgmt.apimanagement.models.ConnectivityStatusContract] + :vartype connectivity_status: list[~azure.mgmt.apimanagement.models.ConnectivityStatusContract] """ _validation = { @@ -8574,6 +12173,14 @@ def __init__( connectivity_status: List["ConnectivityStatusContract"], **kwargs ): + """ + :keyword dns_servers: Required. Gets the list of DNS servers IPV4 addresses. + :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[~azure.mgmt.apimanagement.models.ConnectivityStatusContract] + """ super(NetworkStatusContract, self).__init__(**kwargs) self.dns_servers = dns_servers self.connectivity_status = connectivity_status @@ -8582,10 +12189,10 @@ def __init__( class NetworkStatusContractByLocation(msrest.serialization.Model): """Network Status in the Location. - :param location: Location of service. - :type location: str - :param network_status: Network status in Location. - :type network_status: ~azure.mgmt.apimanagement.models.NetworkStatusContract + :ivar location: Location of service. + :vartype location: str + :ivar network_status: Network status in Location. + :vartype network_status: ~azure.mgmt.apimanagement.models.NetworkStatusContract """ _validation = { @@ -8604,6 +12211,12 @@ def __init__( network_status: Optional["NetworkStatusContract"] = None, **kwargs ): + """ + :keyword location: Location of service. + :paramtype location: str + :keyword network_status: Network status in Location. + :paramtype network_status: ~azure.mgmt.apimanagement.models.NetworkStatusContract + """ super(NetworkStatusContractByLocation, self).__init__(**kwargs) self.location = location self.network_status = network_status @@ -8612,12 +12225,12 @@ def __init__( class NotificationCollection(msrest.serialization.Model): """Paged Notification list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.NotificationContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.NotificationContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -8634,6 +12247,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.NotificationContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(NotificationCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -8645,18 +12266,20 @@ class NotificationContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param title: Title of the Notification. - :type title: str - :param description: Description of the Notification. - :type description: str - :param recipients: Recipient Parameter values. - :type recipients: ~azure.mgmt.apimanagement.models.RecipientsContractProperties + :ivar title: Title of the Notification. + :vartype title: str + :ivar description: Description of the Notification. + :vartype description: str + :ivar recipients: Recipient Parameter values. + :vartype recipients: ~azure.mgmt.apimanagement.models.RecipientsContractProperties """ _validation = { @@ -8683,6 +12306,14 @@ def __init__( recipients: Optional["RecipientsContractProperties"] = None, **kwargs ): + """ + :keyword title: Title of the Notification. + :paramtype title: str + :keyword description: Description of the Notification. + :paramtype description: str + :keyword recipients: Recipient Parameter values. + :paramtype recipients: ~azure.mgmt.apimanagement.models.RecipientsContractProperties + """ super(NotificationContract, self).__init__(**kwargs) self.title = title self.description = description @@ -8692,10 +12323,10 @@ def __init__( class OAuth2AuthenticationSettingsContract(msrest.serialization.Model): """API OAuth2 Authentication settings details. - :param authorization_server_id: OAuth authorization server identifier. - :type authorization_server_id: str - :param scope: operations scope. - :type scope: str + :ivar authorization_server_id: OAuth authorization server identifier. + :vartype authorization_server_id: str + :ivar scope: operations scope. + :vartype scope: str """ _attribute_map = { @@ -8710,6 +12341,12 @@ def __init__( 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) self.authorization_server_id = authorization_server_id self.scope = scope @@ -8718,10 +12355,10 @@ def __init__( class OpenIdAuthenticationSettingsContract(msrest.serialization.Model): """API OAuth2 Authentication settings details. - :param openid_provider_id: OAuth authorization server identifier. - :type openid_provider_id: str - :param bearer_token_sending_methods: How to send token to the server. - :type bearer_token_sending_methods: list[str or + :ivar openid_provider_id: OAuth authorization server identifier. + :vartype openid_provider_id: str + :ivar bearer_token_sending_methods: How to send token to the server. + :vartype bearer_token_sending_methods: list[str or ~azure.mgmt.apimanagement.models.BearerTokenSendingMethods] """ @@ -8737,6 +12374,13 @@ def __init__( bearer_token_sending_methods: Optional[List[Union[str, "BearerTokenSendingMethods"]]] = None, **kwargs ): + """ + :keyword openid_provider_id: OAuth authorization server identifier. + :paramtype openid_provider_id: str + :keyword bearer_token_sending_methods: How to send token to the server. + :paramtype bearer_token_sending_methods: list[str or + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethods] + """ super(OpenIdAuthenticationSettingsContract, self).__init__(**kwargs) self.openid_provider_id = openid_provider_id self.bearer_token_sending_methods = bearer_token_sending_methods @@ -8745,12 +12389,12 @@ def __init__( class OpenIdConnectProviderCollection(msrest.serialization.Model): """Paged OpenIdProviders list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -8767,6 +12411,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(OpenIdConnectProviderCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -8778,22 +12430,24 @@ class OpenidConnectProviderContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param display_name: User-friendly OpenID Connect Provider name. - :type display_name: str - :param description: User-friendly description of OpenID Connect Provider. - :type description: str - :param metadata_endpoint: Metadata endpoint URI. - :type metadata_endpoint: str - :param client_id: Client ID of developer console which is the client application. - :type client_id: str - :param client_secret: Client Secret of developer console which is the client application. - :type client_secret: str + :ivar display_name: User-friendly OpenID Connect Provider name. + :vartype display_name: str + :ivar description: User-friendly description of OpenID Connect Provider. + :vartype description: str + :ivar metadata_endpoint: Metadata endpoint URI. + :vartype metadata_endpoint: str + :ivar client_id: Client ID of developer console which is the client application. + :vartype client_id: str + :ivar client_secret: Client Secret of developer console which is the client application. + :vartype client_secret: str """ _validation = { @@ -8824,6 +12478,18 @@ def __init__( client_secret: Optional[str] = None, **kwargs ): + """ + :keyword display_name: User-friendly OpenID Connect Provider name. + :paramtype display_name: str + :keyword description: User-friendly description of OpenID Connect Provider. + :paramtype description: str + :keyword metadata_endpoint: Metadata endpoint URI. + :paramtype metadata_endpoint: str + :keyword client_id: Client ID of developer console which is the client application. + :paramtype client_id: str + :keyword client_secret: Client Secret of developer console which is the client application. + :paramtype client_secret: str + """ super(OpenidConnectProviderContract, self).__init__(**kwargs) self.display_name = display_name self.description = description @@ -8835,16 +12501,16 @@ def __init__( class OpenidConnectProviderUpdateContract(msrest.serialization.Model): """Parameters supplied to the Update OpenID Connect Provider operation. - :param display_name: User-friendly OpenID Connect Provider name. - :type display_name: str - :param description: User-friendly description of OpenID Connect Provider. - :type description: str - :param metadata_endpoint: Metadata endpoint URI. - :type metadata_endpoint: str - :param client_id: Client ID of developer console which is the client application. - :type client_id: str - :param client_secret: Client Secret of developer console which is the client application. - :type client_secret: str + :ivar display_name: User-friendly OpenID Connect Provider name. + :vartype display_name: str + :ivar description: User-friendly description of OpenID Connect Provider. + :vartype description: str + :ivar metadata_endpoint: Metadata endpoint URI. + :vartype metadata_endpoint: str + :ivar client_id: Client ID of developer console which is the client application. + :vartype client_id: str + :ivar client_secret: Client Secret of developer console which is the client application. + :vartype client_secret: str """ _validation = { @@ -8869,6 +12535,18 @@ def __init__( client_secret: Optional[str] = None, **kwargs ): + """ + :keyword display_name: User-friendly OpenID Connect Provider name. + :paramtype display_name: str + :keyword description: User-friendly description of OpenID Connect Provider. + :paramtype description: str + :keyword metadata_endpoint: Metadata endpoint URI. + :paramtype metadata_endpoint: str + :keyword client_id: Client ID of developer console which is the client application. + :paramtype client_id: str + :keyword client_secret: Client Secret of developer console which is the client application. + :paramtype client_secret: str + """ super(OpenidConnectProviderUpdateContract, self).__init__(**kwargs) self.display_name = display_name self.description = description @@ -8880,14 +12558,14 @@ def __init__( class Operation(msrest.serialization.Model): """REST API operation. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The object that describes the operation. - :type display: ~azure.mgmt.apimanagement.models.OperationDisplay - :param origin: The operation origin. - :type origin: str - :param properties: The operation properties. - :type properties: any + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that describes the operation. + :vartype display: ~azure.mgmt.apimanagement.models.OperationDisplay + :ivar origin: The operation origin. + :vartype origin: str + :ivar properties: The operation properties. + :vartype properties: any """ _attribute_map = { @@ -8906,6 +12584,16 @@ def __init__( properties: Optional[Any] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The object that describes the operation. + :paramtype display: ~azure.mgmt.apimanagement.models.OperationDisplay + :keyword origin: The operation origin. + :paramtype origin: str + :keyword properties: The operation properties. + :paramtype properties: any + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -8920,8 +12608,8 @@ class OperationCollection(msrest.serialization.Model): :ivar value: Page values. :vartype value: list[~azure.mgmt.apimanagement.models.OperationContract] - :param count: Total record count number across all pages. - :type count: long + :ivar count: Total record count number across all pages. + :vartype count: long :ivar next_link: Next page link if any. :vartype next_link: str """ @@ -8943,6 +12631,10 @@ def __init__( count: Optional[int] = None, **kwargs ): + """ + :keyword count: Total record count number across all pages. + :paramtype count: long + """ super(OperationCollection, self).__init__(**kwargs) self.value = None self.count = count @@ -8950,34 +12642,36 @@ def __init__( class OperationContract(Resource): - """Api Operation details. + """API Operation details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param template_parameters: Collection of URL template parameters. - :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :param description: Description of the operation. May include HTML formatting tags. - :type description: str - :param request: An entity containing request details. - :type request: ~azure.mgmt.apimanagement.models.RequestContract - :param responses: Array of Operation responses. - :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :param policies: Operation Policies. - :type policies: str - :param display_name: Operation Name. - :type display_name: str - :param method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not + :ivar template_parameters: Collection of URL template parameters. + :vartype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :ivar description: Description of the operation. May include HTML formatting tags. + :vartype description: str + :ivar request: An entity containing request details. + :vartype request: ~azure.mgmt.apimanagement.models.RequestContract + :ivar responses: Array of Operation responses. + :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] + :ivar policies: Operation Policies. + :vartype policies: str + :ivar display_name: Operation Name. + :vartype display_name: str + :ivar method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not limited by only them. - :type method: str - :param url_template: Relative URL template identifying the target resource for this operation. + :vartype method: str + :ivar url_template: Relative URL template identifying the target resource for this operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. - :type url_template: str + :vartype url_template: str """ _validation = { @@ -9016,6 +12710,26 @@ def __init__( url_template: Optional[str] = None, **kwargs ): + """ + :keyword template_parameters: Collection of URL template parameters. + :paramtype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :keyword description: Description of the operation. May include HTML formatting tags. + :paramtype description: str + :keyword request: An entity containing request details. + :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract + :keyword responses: Array of Operation responses. + :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] + :keyword policies: Operation Policies. + :paramtype policies: str + :keyword display_name: Operation Name. + :paramtype display_name: str + :keyword method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but + not limited by only them. + :paramtype method: str + :keyword url_template: Relative URL template identifying the target resource for this + operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. + :paramtype url_template: str + """ super(OperationContract, self).__init__(**kwargs) self.template_parameters = template_parameters self.description = description @@ -9028,18 +12742,18 @@ def __init__( class OperationEntityBaseContract(msrest.serialization.Model): - """Api Operation Entity Base Contract details. + """API Operation Entity Base Contract details. - :param template_parameters: Collection of URL template parameters. - :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :param description: Description of the operation. May include HTML formatting tags. - :type description: str - :param request: An entity containing request details. - :type request: ~azure.mgmt.apimanagement.models.RequestContract - :param responses: Array of Operation responses. - :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :param policies: Operation Policies. - :type policies: str + :ivar template_parameters: Collection of URL template parameters. + :vartype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :ivar description: Description of the operation. May include HTML formatting tags. + :vartype description: str + :ivar request: An entity containing request details. + :vartype request: ~azure.mgmt.apimanagement.models.RequestContract + :ivar responses: Array of Operation responses. + :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] + :ivar policies: Operation Policies. + :vartype policies: str """ _validation = { @@ -9064,6 +12778,18 @@ def __init__( policies: Optional[str] = None, **kwargs ): + """ + :keyword template_parameters: Collection of URL template parameters. + :paramtype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :keyword description: Description of the operation. May include HTML formatting tags. + :paramtype description: str + :keyword request: An entity containing request details. + :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract + :keyword responses: Array of Operation responses. + :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] + :keyword policies: Operation Policies. + :paramtype policies: str + """ super(OperationEntityBaseContract, self).__init__(**kwargs) self.template_parameters = template_parameters self.description = description @@ -9077,24 +12803,24 @@ class OperationContractProperties(OperationEntityBaseContract): All required parameters must be populated in order to send to Azure. - :param template_parameters: Collection of URL template parameters. - :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :param description: Description of the operation. May include HTML formatting tags. - :type description: str - :param request: An entity containing request details. - :type request: ~azure.mgmt.apimanagement.models.RequestContract - :param responses: Array of Operation responses. - :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :param policies: Operation Policies. - :type policies: str - :param display_name: Required. Operation Name. - :type display_name: str - :param method: Required. A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, - POST but not limited by only them. - :type method: str - :param url_template: Required. Relative URL template identifying the target resource for this + :ivar template_parameters: Collection of URL template parameters. + :vartype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :ivar description: Description of the operation. May include HTML formatting tags. + :vartype description: str + :ivar request: An entity containing request details. + :vartype request: ~azure.mgmt.apimanagement.models.RequestContract + :ivar responses: Array of Operation responses. + :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] + :ivar policies: Operation Policies. + :vartype policies: str + :ivar display_name: Required. Operation Name. + :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. + :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}. - :type url_template: str + :vartype url_template: str """ _validation = { @@ -9128,6 +12854,26 @@ def __init__( policies: Optional[str] = None, **kwargs ): + """ + :keyword template_parameters: Collection of URL template parameters. + :paramtype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :keyword description: Description of the operation. May include HTML formatting tags. + :paramtype description: str + :keyword request: An entity containing request details. + :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract + :keyword responses: Array of Operation responses. + :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] + :keyword policies: Operation Policies. + :paramtype policies: str + :keyword display_name: Required. Operation Name. + :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. + :paramtype method: str + :keyword url_template: Required. Relative URL template identifying the target resource for this + operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. + :paramtype url_template: str + """ super(OperationContractProperties, self).__init__(template_parameters=template_parameters, description=description, request=request, responses=responses, policies=policies, **kwargs) self.display_name = display_name self.method = method @@ -9137,14 +12883,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that describes the operation. - :param provider: Friendly name of the resource provider. - :type provider: str - :param operation: Operation type: read, write, delete, listKeys/action, etc. - :type operation: str - :param resource: Resource type on which the operation is performed. - :type resource: str - :param description: Friendly name of the operation. - :type description: str + :ivar provider: Friendly name of the resource provider. + :vartype provider: str + :ivar operation: Operation type: read, write, delete, listKeys/action, etc. + :vartype operation: str + :ivar resource: Resource type on which the operation is performed. + :vartype resource: str + :ivar description: Friendly name of the operation. + :vartype description: str """ _attribute_map = { @@ -9163,6 +12909,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Friendly name of the resource provider. + :paramtype provider: str + :keyword operation: Operation type: read, write, delete, listKeys/action, etc. + :paramtype operation: str + :keyword resource: Resource type on which the operation is performed. + :paramtype resource: str + :keyword description: Friendly name of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.operation = operation @@ -9173,10 +12929,10 @@ def __init__( class OperationListResult(msrest.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. - :param value: List of operations supported by the resource provider. - :type value: list[~azure.mgmt.apimanagement.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.apimanagement.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -9191,6 +12947,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of operations supported by the resource provider. + :paramtype value: list[~azure.mgmt.apimanagement.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -9201,27 +12963,29 @@ class OperationResultContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param id_properties_id: Operation result identifier. - :type id_properties_id: str - :param status: Status of an async operation. Possible values include: "Started", "InProgress", + :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". - :type status: str or ~azure.mgmt.apimanagement.models.AsyncOperationStatus - :param started: Start time of an async operation. The date conforms to the following format: + :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. - :type started: ~datetime.datetime - :param updated: Last update time of an async operation. The date conforms to the following + :vartype started: ~datetime.datetime + :ivar updated: Last update time of an async operation. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type updated: ~datetime.datetime - :param result_info: Optional result info. - :type result_info: str - :param error: Error Body Contract. - :type error: ~azure.mgmt.apimanagement.models.ErrorResponseBody + :vartype updated: ~datetime.datetime + :ivar result_info: Optional result info. + :vartype result_info: str + :ivar error: Error Body Contract. + :vartype error: ~azure.mgmt.apimanagement.models.ErrorResponseBody :ivar action_log: This property if only provided as part of the TenantConfiguration_Validate operation. It contains the log the entities which will be updated/created/deleted as part of the TenantConfiguration_Deploy operation. @@ -9259,6 +13023,23 @@ def __init__( error: Optional["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 ~azure.mgmt.apimanagement.models.AsyncOperationStatus + :keyword started: Start time of an async operation. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :paramtype started: ~datetime.datetime + :keyword updated: Last update time of an async operation. The date conforms to the following + format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :paramtype updated: ~datetime.datetime + :keyword result_info: Optional result info. + :paramtype result_info: str + :keyword error: Error Body Contract. + :paramtype error: ~azure.mgmt.apimanagement.models.ErrorResponseBody + """ super(OperationResultContract, self).__init__(**kwargs) self.id_properties_id = id_properties_id self.status = status @@ -9272,12 +13053,12 @@ def __init__( class OperationResultLogItemContract(msrest.serialization.Model): """Log of the entity being created, updated or deleted. - :param object_type: The type of entity contract. - :type object_type: str - :param action: Action like create/update/delete. - :type action: str - :param object_key: Identifier of the entity being created/updated/deleted. - :type object_key: str + :ivar object_type: The type of entity contract. + :vartype object_type: str + :ivar action: Action like create/update/delete. + :vartype action: str + :ivar object_key: Identifier of the entity being created/updated/deleted. + :vartype object_key: str """ _attribute_map = { @@ -9294,6 +13075,14 @@ def __init__( object_key: Optional[str] = None, **kwargs ): + """ + :keyword object_type: The type of entity contract. + :paramtype object_type: str + :keyword action: Action like create/update/delete. + :paramtype action: str + :keyword object_key: Identifier of the entity being created/updated/deleted. + :paramtype object_key: str + """ super(OperationResultLogItemContract, self).__init__(**kwargs) self.object_type = object_type self.action = action @@ -9305,15 +13094,15 @@ class OperationTagResourceContractProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param id: Identifier of the operation in form /operations/{operationId}. - :type id: str + :ivar id: Identifier of the operation in form /operations/{operationId}. + :vartype id: str :ivar name: Operation name. :vartype name: str - :ivar api_name: Api Name. + :ivar api_name: API Name. :vartype api_name: str - :ivar api_revision: Api Revision. + :ivar api_revision: API Revision. :vartype api_revision: str - :ivar api_version: Api Version. + :ivar api_version: API Version. :vartype api_version: str :ivar description: Operation Description. :vartype description: str @@ -9352,6 +13141,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Identifier of the operation in form /operations/{operationId}. + :paramtype id: str + """ super(OperationTagResourceContractProperties, self).__init__(**kwargs) self.id = id self.name = None @@ -9364,26 +13157,26 @@ def __init__( class OperationUpdateContract(msrest.serialization.Model): - """Api Operation Update Contract details. - - :param template_parameters: Collection of URL template parameters. - :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :param description: Description of the operation. May include HTML formatting tags. - :type description: str - :param request: An entity containing request details. - :type request: ~azure.mgmt.apimanagement.models.RequestContract - :param responses: Array of Operation responses. - :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :param policies: Operation Policies. - :type policies: str - :param display_name: Operation Name. - :type display_name: str - :param method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not + """API Operation Update Contract details. + + :ivar template_parameters: Collection of URL template parameters. + :vartype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :ivar description: Description of the operation. May include HTML formatting tags. + :vartype description: str + :ivar request: An entity containing request details. + :vartype request: ~azure.mgmt.apimanagement.models.RequestContract + :ivar responses: Array of Operation responses. + :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] + :ivar policies: Operation Policies. + :vartype policies: str + :ivar display_name: Operation Name. + :vartype display_name: str + :ivar method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not limited by only them. - :type method: str - :param url_template: Relative URL template identifying the target resource for this operation. + :vartype method: str + :ivar url_template: Relative URL template identifying the target resource for this operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. - :type url_template: str + :vartype url_template: str """ _validation = { @@ -9416,6 +13209,26 @@ def __init__( url_template: Optional[str] = None, **kwargs ): + """ + :keyword template_parameters: Collection of URL template parameters. + :paramtype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :keyword description: Description of the operation. May include HTML formatting tags. + :paramtype description: str + :keyword request: An entity containing request details. + :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract + :keyword responses: Array of Operation responses. + :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] + :keyword policies: Operation Policies. + :paramtype policies: str + :keyword display_name: Operation Name. + :paramtype display_name: str + :keyword method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but + not limited by only them. + :paramtype method: str + :keyword url_template: Relative URL template identifying the target resource for this + operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. + :paramtype url_template: str + """ super(OperationUpdateContract, self).__init__(**kwargs) self.template_parameters = template_parameters self.description = description @@ -9430,24 +13243,24 @@ def __init__( class OperationUpdateContractProperties(OperationEntityBaseContract): """Operation Update Contract Properties. - :param template_parameters: Collection of URL template parameters. - :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :param description: Description of the operation. May include HTML formatting tags. - :type description: str - :param request: An entity containing request details. - :type request: ~azure.mgmt.apimanagement.models.RequestContract - :param responses: Array of Operation responses. - :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :param policies: Operation Policies. - :type policies: str - :param display_name: Operation Name. - :type display_name: str - :param method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not + :ivar template_parameters: Collection of URL template parameters. + :vartype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :ivar description: Description of the operation. May include HTML formatting tags. + :vartype description: str + :ivar request: An entity containing request details. + :vartype request: ~azure.mgmt.apimanagement.models.RequestContract + :ivar responses: Array of Operation responses. + :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] + :ivar policies: Operation Policies. + :vartype policies: str + :ivar display_name: Operation Name. + :vartype display_name: str + :ivar method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not limited by only them. - :type method: str - :param url_template: Relative URL template identifying the target resource for this operation. + :vartype method: str + :ivar url_template: Relative URL template identifying the target resource for this operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. - :type url_template: str + :vartype url_template: str """ _validation = { @@ -9480,29 +13293,127 @@ def __init__( url_template: Optional[str] = None, **kwargs ): + """ + :keyword template_parameters: Collection of URL template parameters. + :paramtype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :keyword description: Description of the operation. May include HTML formatting tags. + :paramtype description: str + :keyword request: An entity containing request details. + :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract + :keyword responses: Array of Operation responses. + :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] + :keyword policies: Operation Policies. + :paramtype policies: str + :keyword display_name: Operation Name. + :paramtype display_name: str + :keyword method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but + not limited by only them. + :paramtype method: str + :keyword url_template: Relative URL template identifying the target resource for this + operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. + :paramtype url_template: str + """ super(OperationUpdateContractProperties, self).__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): + """Endpoints accessed for a common purpose that the Api Management Service requires outbound network access to. + + :ivar category: The type of service accessed by the Api Management Service, e.g., Azure + Storage, Azure SQL Database, and Azure Active Directory. + :vartype category: str + :ivar endpoints: The endpoints that the Api Management Service reaches the service at. + :vartype endpoints: list[~azure.mgmt.apimanagement.models.EndpointDependency] + """ + + _attribute_map = { + 'category': {'key': 'category', 'type': 'str'}, + 'endpoints': {'key': 'endpoints', 'type': '[EndpointDependency]'}, + } + + def __init__( + self, + *, + category: Optional[str] = None, + endpoints: Optional[List["EndpointDependency"]] = None, + **kwargs + ): + """ + :keyword category: The type of service accessed by the Api Management Service, e.g., Azure + Storage, Azure SQL Database, and Azure Active Directory. + :paramtype category: str + :keyword endpoints: The endpoints that the Api Management Service reaches the service at. + :paramtype endpoints: list[~azure.mgmt.apimanagement.models.EndpointDependency] + """ + super(OutboundEnvironmentEndpoint, self).__init__(**kwargs) + self.category = category + self.endpoints = endpoints + + +class OutboundEnvironmentEndpointList(msrest.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[~azure.mgmt.apimanagement.models.OutboundEnvironmentEndpoint] + :ivar next_link: Link to next page of resources. + :vartype next_link: str + """ + + _validation = { + 'value': {'required': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OutboundEnvironmentEndpoint]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: List["OutboundEnvironmentEndpoint"], + **kwargs + ): + """ + :keyword value: Required. Collection of resources. + :paramtype value: list[~azure.mgmt.apimanagement.models.OutboundEnvironmentEndpoint] + """ + super(OutboundEnvironmentEndpointList, self).__init__(**kwargs) + self.value = value + self.next_link = None + + class ParameterContract(msrest.serialization.Model): """Operation parameters details. All required parameters must be populated in order to send to Azure. - :param name: Required. Parameter name. - :type name: str - :param description: Parameter description. - :type description: str - :param type: Required. Parameter type. - :type type: str - :param default_value: Default parameter value. - :type default_value: str - :param required: Specifies whether parameter is required or not. - :type required: bool - :param values: Parameter values. - :type values: list[str] + :ivar name: Required. Parameter name. + :vartype name: str + :ivar description: Parameter description. + :vartype description: str + :ivar type: Required. Parameter type. + :vartype type: str + :ivar default_value: Default parameter value. + :vartype default_value: str + :ivar required: Specifies whether parameter is required or not. + :vartype required: bool + :ivar values: Parameter values. + :vartype values: list[str] + :ivar schema_id: Schema identifier. + :vartype schema_id: str + :ivar type_name: Type name defined by the schema. + :vartype type_name: str + :ivar examples: Exampled defined for the parameter. + :vartype examples: dict[str, ~azure.mgmt.apimanagement.models.ParameterExampleContract] """ _validation = { @@ -9517,6 +13428,9 @@ class ParameterContract(msrest.serialization.Model): '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__( @@ -9528,8 +13442,31 @@ def __init__( default_value: Optional[str] = None, required: Optional[bool] = None, values: Optional[List[str]] = None, - **kwargs - ): + schema_id: Optional[str] = None, + type_name: Optional[str] = None, + examples: Optional[Dict[str, "ParameterExampleContract"]] = None, + **kwargs + ): + """ + :keyword name: Required. Parameter name. + :paramtype name: str + :keyword description: Parameter description. + :paramtype description: str + :keyword type: Required. Parameter type. + :paramtype type: str + :keyword default_value: Default parameter value. + :paramtype default_value: str + :keyword required: Specifies whether parameter is required or not. + :paramtype required: bool + :keyword values: Parameter values. + :paramtype values: list[str] + :keyword schema_id: Schema identifier. + :paramtype schema_id: str + :keyword type_name: Type name defined by the schema. + :paramtype type_name: str + :keyword examples: Exampled defined for the parameter. + :paramtype examples: dict[str, ~azure.mgmt.apimanagement.models.ParameterExampleContract] + """ super(ParameterContract, self).__init__(**kwargs) self.name = name self.description = description @@ -9537,15 +13474,64 @@ def __init__( self.default_value = default_value self.required = required self.values = values + self.schema_id = schema_id + self.type_name = type_name + self.examples = examples + + +class ParameterExampleContract(msrest.serialization.Model): + """Parameter example. + + :ivar summary: Short description for the example. + :vartype summary: str + :ivar description: Long description for the example. + :vartype description: str + :ivar value: Example value. May be a primitive value, or an object. + :vartype value: any + :ivar external_value: A URL that points to the literal example. + :vartype external_value: str + """ + + _attribute_map = { + 'summary': {'key': 'summary', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'object'}, + 'external_value': {'key': 'externalValue', 'type': 'str'}, + } + + def __init__( + self, + *, + summary: Optional[str] = None, + description: Optional[str] = None, + value: Optional[Any] = None, + external_value: Optional[str] = None, + **kwargs + ): + """ + :keyword summary: Short description for the example. + :paramtype summary: str + :keyword description: Long description for the example. + :paramtype description: str + :keyword value: Example value. May be a primitive value, or an object. + :paramtype value: any + :keyword external_value: A URL that points to the literal example. + :paramtype external_value: str + """ + super(ParameterExampleContract, self).__init__(**kwargs) + self.summary = summary + self.description = description + self.value = value + self.external_value = external_value class PipelineDiagnosticSettings(msrest.serialization.Model): """Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. - :param request: Diagnostic settings for request. - :type request: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic - :param response: Diagnostic settings for response. - :type response: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic + :ivar request: Diagnostic settings for request. + :vartype request: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic + :ivar response: Diagnostic settings for response. + :vartype response: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic """ _attribute_map = { @@ -9560,6 +13546,12 @@ def __init__( response: Optional["HttpMessageDiagnostic"] = None, **kwargs ): + """ + :keyword request: Diagnostic settings for request. + :paramtype request: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic + :keyword response: Diagnostic settings for response. + :paramtype response: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic + """ super(PipelineDiagnosticSettings, self).__init__(**kwargs) self.request = request self.response = response @@ -9568,12 +13560,12 @@ def __init__( class PolicyCollection(msrest.serialization.Model): """The response of the list policy operation. - :param value: Policy Contract value. - :type value: list[~azure.mgmt.apimanagement.models.PolicyContract] - :param count: Total record count number. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Policy Contract value. + :vartype value: list[~azure.mgmt.apimanagement.models.PolicyContract] + :ivar count: Total record count number. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -9590,6 +13582,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Policy Contract value. + :paramtype value: list[~azure.mgmt.apimanagement.models.PolicyContract] + :keyword count: Total record count number. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(PolicyCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -9601,17 +13601,19 @@ class PolicyContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param value: Contents of the Policy as defined by the format. - :type value: str - :param format: Format of the policyContent. Possible values include: "xml", "xml-link", + :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". - :type format: str or ~azure.mgmt.apimanagement.models.PolicyContentFormat + :vartype format: str or ~azure.mgmt.apimanagement.models.PolicyContentFormat """ _validation = { @@ -9635,6 +13637,13 @@ def __init__( format: Optional[Union[str, "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 ~azure.mgmt.apimanagement.models.PolicyContentFormat + """ super(PolicyContract, self).__init__(**kwargs) self.value = value self.format = format @@ -9643,10 +13652,10 @@ def __init__( class PolicyDescriptionCollection(msrest.serialization.Model): """Descriptions of APIM policies. - :param value: Descriptions of APIM policies. - :type value: list[~azure.mgmt.apimanagement.models.PolicyDescriptionContract] - :param count: Total record count number. - :type count: long + :ivar value: Descriptions of APIM policies. + :vartype value: list[~azure.mgmt.apimanagement.models.PolicyDescriptionContract] + :ivar count: Total record count number. + :vartype count: long """ _attribute_map = { @@ -9661,6 +13670,12 @@ def __init__( count: Optional[int] = None, **kwargs ): + """ + :keyword value: Descriptions of APIM policies. + :paramtype value: list[~azure.mgmt.apimanagement.models.PolicyDescriptionContract] + :keyword count: Total record count number. + :paramtype count: long + """ super(PolicyDescriptionCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -9671,11 +13686,13 @@ class PolicyDescriptionContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str :ivar description: Policy description. :vartype description: str @@ -9703,6 +13720,8 @@ def __init__( self, **kwargs ): + """ + """ super(PolicyDescriptionContract, self).__init__(**kwargs) self.description = None self.scope = None @@ -9713,21 +13732,24 @@ class PortalDelegationSettings(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param url: A delegation Url. - :type url: str - :param validation_key: A base64-encoded validation key to validate, that a request is coming + :ivar url: A delegation Url. + :vartype url: str + :ivar validation_key: A base64-encoded validation key to validate, that a request is coming from Azure API Management. - :type validation_key: str - :param subscriptions: Subscriptions delegation settings. - :type subscriptions: ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties - :param user_registration: User registration delegation settings. - :type user_registration: + :vartype validation_key: str + :ivar subscriptions: Subscriptions delegation settings. + :vartype subscriptions: + ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties + :ivar user_registration: User registration delegation settings. + :vartype user_registration: ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties """ @@ -9756,6 +13778,19 @@ def __init__( user_registration: Optional["RegistrationDelegationSettingsProperties"] = None, **kwargs ): + """ + :keyword url: A delegation Url. + :paramtype url: str + :keyword validation_key: A base64-encoded validation key to validate, that a request is coming + from Azure API Management. + :paramtype validation_key: str + :keyword subscriptions: Subscriptions delegation settings. + :paramtype subscriptions: + ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties + :keyword user_registration: User registration delegation settings. + :paramtype user_registration: + ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties + """ super(PortalDelegationSettings, self).__init__(**kwargs) self.url = url self.validation_key = validation_key @@ -9788,32 +13823,36 @@ def __init__( self, **kwargs ): + """ + """ super(PortalRevisionCollection, self).__init__(**kwargs) self.value = None self.next_link = None class PortalRevisionContract(Resource): - """Portal revisions contract details. + """Portal Revision's contract details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param description: Portal revision description. - :type description: str + :ivar description: Portal revision description. + :vartype description: str :ivar status_details: Portal revision publishing status details. :vartype status_details: str - :ivar status: Portal revision publishing status. Possible values include: "pending", + :ivar status: Status of the portal's revision. Possible values include: "pending", "publishing", "completed", "failed". :vartype status: str or ~azure.mgmt.apimanagement.models.PortalRevisionStatus - :param is_current: Indicates if the Portal Revision is public. - :type is_current: bool - :ivar created_date_time: Portal revision creation date and time. + :ivar is_current: Indicates if the portal's revision is public. + :vartype is_current: bool + :ivar created_date_time: Portal's revision creation date and time. :vartype created_date_time: ~datetime.datetime :ivar updated_date_time: Last updated date and time. :vartype updated_date_time: ~datetime.datetime @@ -9849,6 +13888,12 @@ def __init__( 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) self.description = description self.status_details = None @@ -9858,208 +13903,552 @@ def __init__( self.updated_date_time = None -class PortalSettingsCollection(msrest.serialization.Model): - """Descriptions of APIM policies. +class PortalSettingsCollection(msrest.serialization.Model): + """Descriptions of APIM policies. + + :ivar value: Descriptions of APIM policies. + :vartype value: list[~azure.mgmt.apimanagement.models.PortalSettingsContract] + :ivar count: Total record count number. + :vartype count: long + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PortalSettingsContract]'}, + 'count': {'key': 'count', 'type': 'long'}, + } + + def __init__( + self, + *, + value: Optional[List["PortalSettingsContract"]] = None, + count: Optional[int] = None, + **kwargs + ): + """ + :keyword value: Descriptions of APIM policies. + :paramtype value: list[~azure.mgmt.apimanagement.models.PortalSettingsContract] + :keyword count: Total record count number. + :paramtype count: long + """ + super(PortalSettingsCollection, self).__init__(**kwargs) + self.value = value + self.count = count + + +class PortalSettingsContract(Resource): + """Portal Settings for the Developer Portal. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar url: A delegation Url. + :vartype url: str + :ivar validation_key: A base64-encoded validation key to validate, that a request is coming + from Azure API Management. + :vartype validation_key: str + :ivar subscriptions: Subscriptions delegation settings. + :vartype subscriptions: + ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties + :ivar user_registration: User registration delegation settings. + :vartype user_registration: + ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties + :ivar enabled: Redirect Anonymous users to the Sign-In page. + :vartype enabled: bool + :ivar terms_of_service: Terms of service contract properties. + :vartype terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'url': {'key': 'properties.url', 'type': 'str'}, + 'validation_key': {'key': 'properties.validationKey', 'type': 'str'}, + 'subscriptions': {'key': 'properties.subscriptions', 'type': 'SubscriptionsDelegationSettingsProperties'}, + 'user_registration': {'key': 'properties.userRegistration', 'type': 'RegistrationDelegationSettingsProperties'}, + 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + 'terms_of_service': {'key': 'properties.termsOfService', 'type': 'TermsOfServiceProperties'}, + } + + def __init__( + self, + *, + url: Optional[str] = None, + validation_key: Optional[str] = None, + subscriptions: Optional["SubscriptionsDelegationSettingsProperties"] = None, + user_registration: Optional["RegistrationDelegationSettingsProperties"] = None, + enabled: Optional[bool] = None, + terms_of_service: Optional["TermsOfServiceProperties"] = None, + **kwargs + ): + """ + :keyword url: A delegation Url. + :paramtype url: str + :keyword validation_key: A base64-encoded validation key to validate, that a request is coming + from Azure API Management. + :paramtype validation_key: str + :keyword subscriptions: Subscriptions delegation settings. + :paramtype subscriptions: + ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties + :keyword user_registration: User registration delegation settings. + :paramtype user_registration: + ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties + :keyword enabled: Redirect Anonymous users to the Sign-In page. + :paramtype enabled: bool + :keyword terms_of_service: Terms of service contract properties. + :paramtype terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties + """ + super(PortalSettingsContract, self).__init__(**kwargs) + self.url = url + self.validation_key = validation_key + self.subscriptions = subscriptions + self.user_registration = user_registration + self.enabled = enabled + self.terms_of_service = terms_of_service + + +class PortalSettingValidationKeyContract(msrest.serialization.Model): + """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. + + :ivar validation_key: This is secret value of the validation key in portal settings. + :vartype validation_key: str + """ + + _attribute_map = { + 'validation_key': {'key': 'validationKey', 'type': 'str'}, + } + + def __init__( + self, + *, + validation_key: Optional[str] = None, + **kwargs + ): + """ + :keyword validation_key: This is secret value of the validation key in portal settings. + :paramtype validation_key: str + """ + super(PortalSettingValidationKeyContract, self).__init__(**kwargs) + self.validation_key = validation_key + + +class PortalSigninSettings(Resource): + """Sign-In settings for the Developer Portal. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar enabled: Redirect Anonymous users to the Sign-In page. + :vartype enabled: bool + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + **kwargs + ): + """ + :keyword enabled: Redirect Anonymous users to the Sign-In page. + :paramtype enabled: bool + """ + super(PortalSigninSettings, self).__init__(**kwargs) + self.enabled = enabled + + +class PortalSignupSettings(Resource): + """Sign-Up settings for a developer portal. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar enabled: Allow users to sign up on a developer portal. + :vartype enabled: bool + :ivar terms_of_service: Terms of service contract properties. + :vartype terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + 'terms_of_service': {'key': 'properties.termsOfService', 'type': 'TermsOfServiceProperties'}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + terms_of_service: Optional["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: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties + """ + super(PortalSignupSettings, self).__init__(**kwargs) + self.enabled = enabled + self.terms_of_service = terms_of_service + + +class PrivateEndpoint(msrest.serialization.Model): + """The Private Endpoint resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ARM identifier for Private Endpoint. + :vartype id: str + """ + + _validation = { + 'id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(PrivateEndpoint, self).__init__(**kwargs) + self.id = None + + +class PrivateEndpointConnection(Resource): + """The Private Endpoint Connection resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar private_endpoint: The resource of private end point. + :vartype private_endpoint: ~azure.mgmt.apimanagement.models.PrivateEndpoint + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. + :vartype private_link_service_connection_state: + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState + :ivar provisioning_state: The provisioning state of the private endpoint connection resource. + Possible values include: "Succeeded", "Creating", "Deleting", "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionProvisioningState + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, + 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + private_endpoint: Optional["PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + **kwargs + ): + """ + :keyword private_endpoint: The resource of private end point. + :paramtype private_endpoint: ~azure.mgmt.apimanagement.models.PrivateEndpoint + :keyword private_link_service_connection_state: A collection of information about the state of + the connection between service consumer and provider. + :paramtype private_link_service_connection_state: + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState + """ + super(PrivateEndpointConnection, self).__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): + """List of private endpoint connection associated with the specified storage account. - :param value: Descriptions of APIM policies. - :type value: list[~azure.mgmt.apimanagement.models.PortalSettingsContract] - :param count: Total record count number. - :type count: long + :ivar value: Array of private endpoint connections. + :vartype value: list[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PortalSettingsContract]'}, - 'count': {'key': 'count', 'type': 'long'}, + 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, } def __init__( self, *, - value: Optional[List["PortalSettingsContract"]] = None, - count: Optional[int] = None, + value: Optional[List["PrivateEndpointConnection"]] = None, **kwargs ): - super(PortalSettingsCollection, self).__init__(**kwargs) + """ + :keyword value: Array of private endpoint connections. + :paramtype value: list[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] + """ + super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) self.value = value - self.count = count - -class PortalSettingsContract(Resource): - """Portal Settings for the Developer Portal. - Variables are only populated by the server, and will be ignored when sending a request. +class PrivateEndpointConnectionRequest(msrest.serialization.Model): + """A request to approve or reject a private endpoint connection. - :ivar id: Resource ID. + :ivar id: Private Endpoint Connection Resource Id. :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param url: A delegation Url. - :type url: str - :param validation_key: A base64-encoded validation key to validate, that a request is coming - from Azure API Management. - :type validation_key: str - :param subscriptions: Subscriptions delegation settings. - :type subscriptions: ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties - :param user_registration: User registration delegation settings. - :type user_registration: - ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties - :param enabled: Redirect Anonymous users to the Sign-In page. - :type enabled: bool - :param terms_of_service: Terms of service contract properties. - :type terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties + :ivar properties: The connection state of the private endpoint connection. + :vartype properties: + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequestProperties """ - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'url': {'key': 'properties.url', 'type': 'str'}, - 'validation_key': {'key': 'properties.validationKey', 'type': 'str'}, - 'subscriptions': {'key': 'properties.subscriptions', 'type': 'SubscriptionsDelegationSettingsProperties'}, - 'user_registration': {'key': 'properties.userRegistration', 'type': 'RegistrationDelegationSettingsProperties'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'terms_of_service': {'key': 'properties.termsOfService', 'type': 'TermsOfServiceProperties'}, + 'properties': {'key': 'properties', 'type': 'PrivateEndpointConnectionRequestProperties'}, } def __init__( self, *, - url: Optional[str] = None, - validation_key: Optional[str] = None, - subscriptions: Optional["SubscriptionsDelegationSettingsProperties"] = None, - user_registration: Optional["RegistrationDelegationSettingsProperties"] = None, - enabled: Optional[bool] = None, - terms_of_service: Optional["TermsOfServiceProperties"] = None, + id: Optional[str] = None, + properties: Optional["PrivateEndpointConnectionRequestProperties"] = None, **kwargs ): - super(PortalSettingsContract, self).__init__(**kwargs) - self.url = url - self.validation_key = validation_key - self.subscriptions = subscriptions - self.user_registration = user_registration - self.enabled = enabled - self.terms_of_service = terms_of_service + """ + :keyword id: Private Endpoint Connection Resource Id. + :paramtype id: str + :keyword properties: The connection state of the private endpoint connection. + :paramtype properties: + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequestProperties + """ + super(PrivateEndpointConnectionRequest, self).__init__(**kwargs) + self.id = id + self.properties = properties -class PortalSettingValidationKeyContract(msrest.serialization.Model): - """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. +class PrivateEndpointConnectionRequestProperties(msrest.serialization.Model): + """The connection state of the private endpoint connection. - :param validation_key: This is secret value of the validation key in portal settings. - :type validation_key: str + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. + :vartype private_link_service_connection_state: + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState """ _attribute_map = { - 'validation_key': {'key': 'validationKey', 'type': 'str'}, + 'private_link_service_connection_state': {'key': 'privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, } def __init__( self, *, - validation_key: Optional[str] = None, + private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, **kwargs ): - super(PortalSettingValidationKeyContract, self).__init__(**kwargs) - self.validation_key = validation_key + """ + :keyword private_link_service_connection_state: A collection of information about the state of + the connection between service consumer and provider. + :paramtype private_link_service_connection_state: + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState + """ + super(PrivateEndpointConnectionRequestProperties, self).__init__(**kwargs) + self.private_link_service_connection_state = private_link_service_connection_state -class PortalSigninSettings(Resource): - """Sign-In settings for the Developer Portal. +class PrivateLinkResource(Resource): + """A private link resource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param enabled: Redirect Anonymous users to the Sign-In page. - :type enabled: bool + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + :ivar required_zone_names: The private link resource Private link DNS zone name. + :vartype required_zone_names: list[str] """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'group_id': {'readonly': True}, + 'required_members': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + '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, *, - enabled: Optional[bool] = None, + required_zone_names: Optional[List[str]] = None, **kwargs ): - super(PortalSigninSettings, self).__init__(**kwargs) - self.enabled = enabled - + """ + :keyword required_zone_names: The private link resource Private link DNS zone name. + :paramtype required_zone_names: list[str] + """ + super(PrivateLinkResource, self).__init__(**kwargs) + self.group_id = None + self.required_members = None + self.required_zone_names = required_zone_names -class PortalSignupSettings(Resource): - """Sign-Up settings for a developer portal. - Variables are only populated by the server, and will be ignored when sending a request. +class PrivateLinkResourceListResult(msrest.serialization.Model): + """A list of private link resources. - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param enabled: Allow users to sign up on a developer portal. - :type enabled: bool - :param terms_of_service: Terms of service contract properties. - :type terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties + :ivar value: Array of private link resources. + :vartype value: list[~azure.mgmt.apimanagement.models.PrivateLinkResource] """ - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'terms_of_service': {'key': 'properties.termsOfService', 'type': 'TermsOfServiceProperties'}, + 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, } def __init__( self, *, - enabled: Optional[bool] = None, - terms_of_service: Optional["TermsOfServiceProperties"] = None, + value: Optional[List["PrivateLinkResource"]] = None, **kwargs ): - super(PortalSignupSettings, self).__init__(**kwargs) - self.enabled = enabled - self.terms_of_service = terms_of_service + """ + :keyword value: Array of private link resources. + :paramtype value: list[~azure.mgmt.apimanagement.models.PrivateLinkResource] + """ + super(PrivateLinkResourceListResult, self).__init__(**kwargs) + self.value = value + + +class PrivateLinkServiceConnectionState(msrest.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 ~azure.mgmt.apimanagement.models.PrivateEndpointServiceConnectionStatus + :ivar description: The reason for approval/rejection of the connection. + :vartype description: str + :ivar actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :vartype actions_required: str + """ + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "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 + ~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) + self.status = status + self.description = description + self.actions_required = actions_required class ProductCollection(msrest.serialization.Model): """Paged Products list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.ProductContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.ProductContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -10076,6 +14465,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.ProductContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(ProductCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -10087,40 +14484,42 @@ class ProductContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param description: Product description. May include HTML formatting tags. - :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the product will be + :ivar description: Product description. May include HTML formatting tags. + :vartype description: str + :ivar terms: Product terms of use. Developers trying to subscribe to the product will be presented and required to accept these terms before they can complete the subscription process. - :type terms: str - :param subscription_required: Whether a product subscription is required for accessing APIs + :vartype terms: str + :ivar subscription_required: Whether a product subscription is required for accessing APIs included in this product. If true, the product is referred to as "protected" and a valid subscription key is required for a request to an API included in the product to succeed. If false, the product is referred to as "open" and requests to an API included in the product can be made without a subscription key. If property is omitted when creating a new product it's value is assumed to be true. - :type subscription_required: bool - :param approval_required: whether subscription approval is required. If false, new - subscriptions will be approved automatically enabling developers to call the product’s APIs - immediately after subscribing. If true, administrators must manually approve the subscription - before the developer can any of the product’s APIs. Can be present only if subscriptionRequired - property is present and has a value of false. - :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can have to this product + :vartype subscription_required: bool + :ivar approval_required: whether subscription approval is required. If false, new subscriptions + will be approved automatically enabling developers to call the product’s APIs immediately after + subscribing. If true, administrators must manually approve the subscription before the + developer can any of the product’s APIs. Can be present only if subscriptionRequired property + is present and has a value of false. + :vartype approval_required: bool + :ivar subscriptions_limit: Whether the number of subscriptions a user can have to this product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present only if subscriptionRequired property is present and has a value of false. - :type subscriptions_limit: int - :param state: whether product is published or not. Published products are discoverable by users + :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". - :type state: str or ~azure.mgmt.apimanagement.models.ProductState - :param display_name: Product name. - :type display_name: str + :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState + :ivar display_name: Product name. + :vartype display_name: str """ _validation = { @@ -10156,6 +14555,36 @@ def __init__( display_name: Optional[str] = None, **kwargs ): + """ + :keyword description: Product description. May include HTML formatting tags. + :paramtype description: str + :keyword terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. + :paramtype terms: str + :keyword subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. + :paramtype subscription_required: bool + :keyword approval_required: whether subscription approval is required. If false, new + subscriptions will be approved automatically enabling developers to call the product’s APIs + immediately after subscribing. If true, administrators must manually approve the subscription + before the developer can any of the product’s APIs. Can be present only if subscriptionRequired + property is present and has a value of false. + :paramtype approval_required: bool + :keyword subscriptions_limit: Whether the number of subscriptions a user can have to this + product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be + present only if subscriptionRequired property is present and has a value of false. + :paramtype subscriptions_limit: int + :keyword state: whether product is published or not. Published products are discoverable by + users of developer portal. Non published products are visible only to administrators. Default + state of Product is notPublished. Possible values include: "notPublished", "published". + :paramtype state: str or ~azure.mgmt.apimanagement.models.ProductState + :keyword display_name: Product name. + :paramtype display_name: str + """ super(ProductContract, self).__init__(**kwargs) self.description = description self.terms = terms @@ -10169,32 +14598,32 @@ def __init__( class ProductEntityBaseParameters(msrest.serialization.Model): """Product Entity Base Parameters. - :param description: Product description. May include HTML formatting tags. - :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the product will be + :ivar description: Product description. May include HTML formatting tags. + :vartype description: str + :ivar terms: Product terms of use. Developers trying to subscribe to the product will be presented and required to accept these terms before they can complete the subscription process. - :type terms: str - :param subscription_required: Whether a product subscription is required for accessing APIs + :vartype terms: str + :ivar subscription_required: Whether a product subscription is required for accessing APIs included in this product. If true, the product is referred to as "protected" and a valid subscription key is required for a request to an API included in the product to succeed. If false, the product is referred to as "open" and requests to an API included in the product can be made without a subscription key. If property is omitted when creating a new product it's value is assumed to be true. - :type subscription_required: bool - :param approval_required: whether subscription approval is required. If false, new - subscriptions will be approved automatically enabling developers to call the product’s APIs - immediately after subscribing. If true, administrators must manually approve the subscription - before the developer can any of the product’s APIs. Can be present only if subscriptionRequired - property is present and has a value of false. - :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can have to this product + :vartype subscription_required: bool + :ivar approval_required: whether subscription approval is required. If false, new subscriptions + will be approved automatically enabling developers to call the product’s APIs immediately after + subscribing. If true, administrators must manually approve the subscription before the + developer can any of the product’s APIs. Can be present only if subscriptionRequired property + is present and has a value of false. + :vartype approval_required: bool + :ivar subscriptions_limit: Whether the number of subscriptions a user can have to this product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present only if subscriptionRequired property is present and has a value of false. - :type subscriptions_limit: int - :param state: whether product is published or not. Published products are discoverable by users + :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". - :type state: str or ~azure.mgmt.apimanagement.models.ProductState + :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState """ _validation = { @@ -10221,6 +14650,34 @@ def __init__( state: Optional[Union[str, "ProductState"]] = None, **kwargs ): + """ + :keyword description: Product description. May include HTML formatting tags. + :paramtype description: str + :keyword terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. + :paramtype terms: str + :keyword subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. + :paramtype subscription_required: bool + :keyword approval_required: whether subscription approval is required. If false, new + subscriptions will be approved automatically enabling developers to call the product’s APIs + immediately after subscribing. If true, administrators must manually approve the subscription + before the developer can any of the product’s APIs. Can be present only if subscriptionRequired + property is present and has a value of false. + :paramtype approval_required: bool + :keyword subscriptions_limit: Whether the number of subscriptions a user can have to this + product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be + present only if subscriptionRequired property is present and has a value of false. + :paramtype subscriptions_limit: int + :keyword state: whether product is published or not. Published products are discoverable by + users of developer portal. Non published products are visible only to administrators. Default + state of Product is notPublished. Possible values include: "notPublished", "published". + :paramtype state: str or ~azure.mgmt.apimanagement.models.ProductState + """ super(ProductEntityBaseParameters, self).__init__(**kwargs) self.description = description self.terms = terms @@ -10235,34 +14692,34 @@ class ProductContractProperties(ProductEntityBaseParameters): All required parameters must be populated in order to send to Azure. - :param description: Product description. May include HTML formatting tags. - :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the product will be + :ivar description: Product description. May include HTML formatting tags. + :vartype description: str + :ivar terms: Product terms of use. Developers trying to subscribe to the product will be presented and required to accept these terms before they can complete the subscription process. - :type terms: str - :param subscription_required: Whether a product subscription is required for accessing APIs + :vartype terms: str + :ivar subscription_required: Whether a product subscription is required for accessing APIs included in this product. If true, the product is referred to as "protected" and a valid subscription key is required for a request to an API included in the product to succeed. If false, the product is referred to as "open" and requests to an API included in the product can be made without a subscription key. If property is omitted when creating a new product it's value is assumed to be true. - :type subscription_required: bool - :param approval_required: whether subscription approval is required. If false, new - subscriptions will be approved automatically enabling developers to call the product’s APIs - immediately after subscribing. If true, administrators must manually approve the subscription - before the developer can any of the product’s APIs. Can be present only if subscriptionRequired - property is present and has a value of false. - :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can have to this product + :vartype subscription_required: bool + :ivar approval_required: whether subscription approval is required. If false, new subscriptions + will be approved automatically enabling developers to call the product’s APIs immediately after + subscribing. If true, administrators must manually approve the subscription before the + developer can any of the product’s APIs. Can be present only if subscriptionRequired property + is present and has a value of false. + :vartype approval_required: bool + :ivar subscriptions_limit: Whether the number of subscriptions a user can have to this product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present only if subscriptionRequired property is present and has a value of false. - :type subscriptions_limit: int - :param state: whether product is published or not. Published products are discoverable by users + :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". - :type state: str or ~azure.mgmt.apimanagement.models.ProductState - :param display_name: Required. Product name. - :type display_name: str + :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState + :ivar display_name: Required. Product name. + :vartype display_name: str """ _validation = { @@ -10292,6 +14749,36 @@ def __init__( state: Optional[Union[str, "ProductState"]] = None, **kwargs ): + """ + :keyword description: Product description. May include HTML formatting tags. + :paramtype description: str + :keyword terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. + :paramtype terms: str + :keyword subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. + :paramtype subscription_required: bool + :keyword approval_required: whether subscription approval is required. If false, new + subscriptions will be approved automatically enabling developers to call the product’s APIs + immediately after subscribing. If true, administrators must manually approve the subscription + before the developer can any of the product’s APIs. Can be present only if subscriptionRequired + property is present and has a value of false. + :paramtype approval_required: bool + :keyword subscriptions_limit: Whether the number of subscriptions a user can have to this + product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be + present only if subscriptionRequired property is present and has a value of false. + :paramtype subscriptions_limit: int + :keyword state: whether product is published or not. Published products are discoverable by + users of developer portal. Non published products are visible only to administrators. Default + state of Product is notPublished. Possible values include: "notPublished", "published". + :paramtype state: str or ~azure.mgmt.apimanagement.models.ProductState + :keyword display_name: Required. Product name. + :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) self.display_name = display_name @@ -10301,36 +14788,36 @@ class ProductTagResourceContractProperties(ProductEntityBaseParameters): All required parameters must be populated in order to send to Azure. - :param description: Product description. May include HTML formatting tags. - :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the product will be + :ivar description: Product description. May include HTML formatting tags. + :vartype description: str + :ivar terms: Product terms of use. Developers trying to subscribe to the product will be presented and required to accept these terms before they can complete the subscription process. - :type terms: str - :param subscription_required: Whether a product subscription is required for accessing APIs + :vartype terms: str + :ivar subscription_required: Whether a product subscription is required for accessing APIs included in this product. If true, the product is referred to as "protected" and a valid subscription key is required for a request to an API included in the product to succeed. If false, the product is referred to as "open" and requests to an API included in the product can be made without a subscription key. If property is omitted when creating a new product it's value is assumed to be true. - :type subscription_required: bool - :param approval_required: whether subscription approval is required. If false, new - subscriptions will be approved automatically enabling developers to call the product’s APIs - immediately after subscribing. If true, administrators must manually approve the subscription - before the developer can any of the product’s APIs. Can be present only if subscriptionRequired - property is present and has a value of false. - :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can have to this product + :vartype subscription_required: bool + :ivar approval_required: whether subscription approval is required. If false, new subscriptions + will be approved automatically enabling developers to call the product’s APIs immediately after + subscribing. If true, administrators must manually approve the subscription before the + developer can any of the product’s APIs. Can be present only if subscriptionRequired property + is present and has a value of false. + :vartype approval_required: bool + :ivar subscriptions_limit: Whether the number of subscriptions a user can have to this product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present only if subscriptionRequired property is present and has a value of false. - :type subscriptions_limit: int - :param state: whether product is published or not. Published products are discoverable by users + :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". - :type state: str or ~azure.mgmt.apimanagement.models.ProductState - :param id: Identifier of the product in the form of /products/{productId}. - :type id: str - :param name: Required. Product name. - :type name: str + :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. + :vartype name: str """ _validation = { @@ -10362,6 +14849,38 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword description: Product description. May include HTML formatting tags. + :paramtype description: str + :keyword terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. + :paramtype terms: str + :keyword subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. + :paramtype subscription_required: bool + :keyword approval_required: whether subscription approval is required. If false, new + subscriptions will be approved automatically enabling developers to call the product’s APIs + immediately after subscribing. If true, administrators must manually approve the subscription + before the developer can any of the product’s APIs. Can be present only if subscriptionRequired + property is present and has a value of false. + :paramtype approval_required: bool + :keyword subscriptions_limit: Whether the number of subscriptions a user can have to this + product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be + present only if subscriptionRequired property is present and has a value of false. + :paramtype subscriptions_limit: int + :keyword state: whether product is published or not. Published products are discoverable by + users of developer portal. Non published products are visible only to administrators. Default + state of Product is notPublished. Possible values include: "notPublished", "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. + :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) self.id = id self.name = name @@ -10370,34 +14889,34 @@ def __init__( class ProductUpdateParameters(msrest.serialization.Model): """Product Update parameters. - :param description: Product description. May include HTML formatting tags. - :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the product will be + :ivar description: Product description. May include HTML formatting tags. + :vartype description: str + :ivar terms: Product terms of use. Developers trying to subscribe to the product will be presented and required to accept these terms before they can complete the subscription process. - :type terms: str - :param subscription_required: Whether a product subscription is required for accessing APIs + :vartype terms: str + :ivar subscription_required: Whether a product subscription is required for accessing APIs included in this product. If true, the product is referred to as "protected" and a valid subscription key is required for a request to an API included in the product to succeed. If false, the product is referred to as "open" and requests to an API included in the product can be made without a subscription key. If property is omitted when creating a new product it's value is assumed to be true. - :type subscription_required: bool - :param approval_required: whether subscription approval is required. If false, new - subscriptions will be approved automatically enabling developers to call the product’s APIs - immediately after subscribing. If true, administrators must manually approve the subscription - before the developer can any of the product’s APIs. Can be present only if subscriptionRequired - property is present and has a value of false. - :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can have to this product + :vartype subscription_required: bool + :ivar approval_required: whether subscription approval is required. If false, new subscriptions + will be approved automatically enabling developers to call the product’s APIs immediately after + subscribing. If true, administrators must manually approve the subscription before the + developer can any of the product’s APIs. Can be present only if subscriptionRequired property + is present and has a value of false. + :vartype approval_required: bool + :ivar subscriptions_limit: Whether the number of subscriptions a user can have to this product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present only if subscriptionRequired property is present and has a value of false. - :type subscriptions_limit: int - :param state: whether product is published or not. Published products are discoverable by users + :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". - :type state: str or ~azure.mgmt.apimanagement.models.ProductState - :param display_name: Product name. - :type display_name: str + :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState + :ivar display_name: Product name. + :vartype display_name: str """ _validation = { @@ -10427,6 +14946,36 @@ def __init__( display_name: Optional[str] = None, **kwargs ): + """ + :keyword description: Product description. May include HTML formatting tags. + :paramtype description: str + :keyword terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. + :paramtype terms: str + :keyword subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. + :paramtype subscription_required: bool + :keyword approval_required: whether subscription approval is required. If false, new + subscriptions will be approved automatically enabling developers to call the product’s APIs + immediately after subscribing. If true, administrators must manually approve the subscription + before the developer can any of the product’s APIs. Can be present only if subscriptionRequired + property is present and has a value of false. + :paramtype approval_required: bool + :keyword subscriptions_limit: Whether the number of subscriptions a user can have to this + product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be + present only if subscriptionRequired property is present and has a value of false. + :paramtype subscriptions_limit: int + :keyword state: whether product is published or not. Published products are discoverable by + users of developer portal. Non published products are visible only to administrators. Default + state of Product is notPublished. Possible values include: "notPublished", "published". + :paramtype state: str or ~azure.mgmt.apimanagement.models.ProductState + :keyword display_name: Product name. + :paramtype display_name: str + """ super(ProductUpdateParameters, self).__init__(**kwargs) self.description = description self.terms = terms @@ -10440,34 +14989,34 @@ def __init__( class ProductUpdateProperties(ProductEntityBaseParameters): """Parameters supplied to the Update Product operation. - :param description: Product description. May include HTML formatting tags. - :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the product will be + :ivar description: Product description. May include HTML formatting tags. + :vartype description: str + :ivar terms: Product terms of use. Developers trying to subscribe to the product will be presented and required to accept these terms before they can complete the subscription process. - :type terms: str - :param subscription_required: Whether a product subscription is required for accessing APIs + :vartype terms: str + :ivar subscription_required: Whether a product subscription is required for accessing APIs included in this product. If true, the product is referred to as "protected" and a valid subscription key is required for a request to an API included in the product to succeed. If false, the product is referred to as "open" and requests to an API included in the product can be made without a subscription key. If property is omitted when creating a new product it's value is assumed to be true. - :type subscription_required: bool - :param approval_required: whether subscription approval is required. If false, new - subscriptions will be approved automatically enabling developers to call the product’s APIs - immediately after subscribing. If true, administrators must manually approve the subscription - before the developer can any of the product’s APIs. Can be present only if subscriptionRequired - property is present and has a value of false. - :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can have to this product + :vartype subscription_required: bool + :ivar approval_required: whether subscription approval is required. If false, new subscriptions + will be approved automatically enabling developers to call the product’s APIs immediately after + subscribing. If true, administrators must manually approve the subscription before the + developer can any of the product’s APIs. Can be present only if subscriptionRequired property + is present and has a value of false. + :vartype approval_required: bool + :ivar subscriptions_limit: Whether the number of subscriptions a user can have to this product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present only if subscriptionRequired property is present and has a value of false. - :type subscriptions_limit: int - :param state: whether product is published or not. Published products are discoverable by users + :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". - :type state: str or ~azure.mgmt.apimanagement.models.ProductState - :param display_name: Product name. - :type display_name: str + :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState + :ivar display_name: Product name. + :vartype display_name: str """ _validation = { @@ -10497,6 +15046,36 @@ def __init__( display_name: Optional[str] = None, **kwargs ): + """ + :keyword description: Product description. May include HTML formatting tags. + :paramtype description: str + :keyword terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. + :paramtype terms: str + :keyword subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. + :paramtype subscription_required: bool + :keyword approval_required: whether subscription approval is required. If false, new + subscriptions will be approved automatically enabling developers to call the product’s APIs + immediately after subscribing. If true, administrators must manually approve the subscription + before the developer can any of the product’s APIs. Can be present only if subscriptionRequired + property is present and has a value of false. + :paramtype approval_required: bool + :keyword subscriptions_limit: Whether the number of subscriptions a user can have to this + product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be + present only if subscriptionRequired property is present and has a value of false. + :paramtype subscriptions_limit: int + :keyword state: whether product is published or not. Published products are discoverable by + users of developer portal. Non published products are visible only to administrators. Default + state of Product is notPublished. Possible values include: "notPublished", "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) self.display_name = display_name @@ -10504,12 +15083,12 @@ def __init__( class QuotaCounterCollection(msrest.serialization.Model): """Paged Quota Counter list representation. - :param value: Quota counter values. - :type value: list[~azure.mgmt.apimanagement.models.QuotaCounterContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Quota counter values. + :vartype value: list[~azure.mgmt.apimanagement.models.QuotaCounterContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -10526,6 +15105,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Quota counter values. + :paramtype value: list[~azure.mgmt.apimanagement.models.QuotaCounterContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(QuotaCounterCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -10537,19 +15124,19 @@ class QuotaCounterContract(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param counter_key: Required. The Key value of the Counter. Must not be empty. - :type counter_key: str - :param period_key: Required. Identifier of the Period for which the counter was collected. Must + :ivar counter_key: Required. The Key value of the Counter. Must not be empty. + :vartype counter_key: str + :ivar period_key: Required. Identifier of the Period for which the counter was collected. Must not be empty. - :type period_key: str - :param period_start_time: Required. The date of the start of Counter Period. The date conforms + :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. - :type period_start_time: ~datetime.datetime - :param period_end_time: Required. The date of the end of Counter Period. The date conforms to + :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. - :type period_end_time: ~datetime.datetime - :param value: Quota Value Properties. - :type value: ~azure.mgmt.apimanagement.models.QuotaCounterValueContractProperties + :vartype period_end_time: ~datetime.datetime + :ivar value: Quota Value Properties. + :vartype value: ~azure.mgmt.apimanagement.models.QuotaCounterValueContractProperties """ _validation = { @@ -10577,6 +15164,22 @@ def __init__( value: Optional["QuotaCounterValueContractProperties"] = None, **kwargs ): + """ + :keyword counter_key: Required. The Key value of the Counter. Must not be empty. + :paramtype counter_key: str + :keyword period_key: Required. Identifier of the Period for which the counter was collected. + Must not be empty. + :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. + :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. + :paramtype period_end_time: ~datetime.datetime + :keyword value: Quota Value Properties. + :paramtype value: ~azure.mgmt.apimanagement.models.QuotaCounterValueContractProperties + """ super(QuotaCounterContract, self).__init__(**kwargs) self.counter_key = counter_key self.period_key = period_key @@ -10588,10 +15191,10 @@ def __init__( class QuotaCounterValueContract(msrest.serialization.Model): """Quota counter value details. - :param calls_count: Number of times Counter was called. - :type calls_count: int - :param kb_transferred: Data Transferred in KiloBytes. - :type kb_transferred: float + :ivar calls_count: Number of times Counter was called. + :vartype calls_count: int + :ivar kb_transferred: Data Transferred in KiloBytes. + :vartype kb_transferred: float """ _attribute_map = { @@ -10606,6 +15209,12 @@ def __init__( 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) self.calls_count = calls_count self.kb_transferred = kb_transferred @@ -10614,10 +15223,10 @@ def __init__( class QuotaCounterValueContractProperties(msrest.serialization.Model): """Quota counter value details. - :param calls_count: Number of times Counter was called. - :type calls_count: int - :param kb_transferred: Data Transferred in KiloBytes. - :type kb_transferred: float + :ivar calls_count: Number of times Counter was called. + :vartype calls_count: int + :ivar kb_transferred: Data Transferred in KiloBytes. + :vartype kb_transferred: float """ _attribute_map = { @@ -10632,6 +15241,12 @@ def __init__( 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) self.calls_count = calls_count self.kb_transferred = kb_transferred @@ -10640,10 +15255,10 @@ def __init__( class QuotaCounterValueUpdateContract(msrest.serialization.Model): """Quota counter value details. - :param calls_count: Number of times Counter was called. - :type calls_count: int - :param kb_transferred: Data Transferred in KiloBytes. - :type kb_transferred: float + :ivar calls_count: Number of times Counter was called. + :vartype calls_count: int + :ivar kb_transferred: Data Transferred in KiloBytes. + :vartype kb_transferred: float """ _attribute_map = { @@ -10658,6 +15273,12 @@ def __init__( 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) self.calls_count = calls_count self.kb_transferred = kb_transferred @@ -10666,12 +15287,12 @@ def __init__( class RecipientEmailCollection(msrest.serialization.Model): """Paged Recipient User list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.RecipientEmailContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.RecipientEmailContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -10688,6 +15309,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.RecipientEmailContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(RecipientEmailCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -10699,14 +15328,16 @@ class RecipientEmailContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param email: User Email subscribed to notification. - :type email: str + :ivar email: User Email subscribed to notification. + :vartype email: str """ _validation = { @@ -10728,6 +15359,10 @@ def __init__( email: Optional[str] = None, **kwargs ): + """ + :keyword email: User Email subscribed to notification. + :paramtype email: str + """ super(RecipientEmailContract, self).__init__(**kwargs) self.email = email @@ -10735,10 +15370,10 @@ def __init__( class RecipientsContractProperties(msrest.serialization.Model): """Notification Parameter contract. - :param emails: List of Emails subscribed for the notification. - :type emails: list[str] - :param users: List of Users subscribed for the notification. - :type users: list[str] + :ivar emails: List of Emails subscribed for the notification. + :vartype emails: list[str] + :ivar users: List of Users subscribed for the notification. + :vartype users: list[str] """ _attribute_map = { @@ -10753,6 +15388,12 @@ def __init__( 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) self.emails = emails self.users = users @@ -10761,12 +15402,12 @@ def __init__( class RecipientUserCollection(msrest.serialization.Model): """Paged Recipient User list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.RecipientUserContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.RecipientUserContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -10783,6 +15424,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.RecipientUserContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(RecipientUserCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -10794,14 +15443,16 @@ class RecipientUserContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param user_id: API Management UserId subscribed to notification. - :type user_id: str + :ivar user_id: API Management UserId subscribed to notification. + :vartype user_id: str """ _validation = { @@ -10823,6 +15474,10 @@ def __init__( user_id: Optional[str] = None, **kwargs ): + """ + :keyword user_id: API Management UserId subscribed to notification. + :paramtype user_id: str + """ super(RecipientUserContract, self).__init__(**kwargs) self.user_id = user_id @@ -10834,10 +15489,10 @@ class RegionContract(msrest.serialization.Model): :ivar name: Region name. :vartype name: str - :param is_master_region: whether Region is the master region. - :type is_master_region: bool - :param is_deleted: whether Region is deleted. - :type is_deleted: bool + :ivar is_master_region: whether Region is the master region. + :vartype is_master_region: bool + :ivar is_deleted: whether Region is deleted. + :vartype is_deleted: bool """ _validation = { @@ -10857,6 +15512,12 @@ def __init__( 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) self.name = None self.is_master_region = is_master_region @@ -10866,12 +15527,12 @@ def __init__( class RegionListResult(msrest.serialization.Model): """Lists Regions operation response details. - :param value: Lists of Regions. - :type value: list[~azure.mgmt.apimanagement.models.RegionContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Lists of Regions. + :vartype value: list[~azure.mgmt.apimanagement.models.RegionContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -10888,6 +15549,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Lists of Regions. + :paramtype value: list[~azure.mgmt.apimanagement.models.RegionContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(RegionListResult, self).__init__(**kwargs) self.value = value self.count = count @@ -10897,8 +15566,8 @@ def __init__( class RegistrationDelegationSettingsProperties(msrest.serialization.Model): """User registration delegation settings properties. - :param enabled: Enable or disable delegation for user registration. - :type enabled: bool + :ivar enabled: Enable or disable delegation for user registration. + :vartype enabled: bool """ _attribute_map = { @@ -10911,19 +15580,95 @@ def __init__( enabled: Optional[bool] = None, **kwargs ): + """ + :keyword enabled: Enable or disable delegation for user registration. + :paramtype enabled: bool + """ super(RegistrationDelegationSettingsProperties, self).__init__(**kwargs) self.enabled = enabled +class RemotePrivateEndpointConnectionWrapper(msrest.serialization.Model): + """Remote Private Endpoint Connection resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Private Endpoint connection resource id. + :vartype id: str + :ivar name: Private Endpoint Connection Name. + :vartype name: str + :ivar type: Private Endpoint Connection Resource Type. + :vartype type: str + :ivar private_endpoint: The resource of private end point. + :vartype private_endpoint: ~azure.mgmt.apimanagement.models.ArmIdWrapper + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. + :vartype private_link_service_connection_state: + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState + :ivar provisioning_state: The provisioning state of the private endpoint connection resource. + :vartype provisioning_state: str + :ivar group_ids: All the Group ids. + :vartype group_ids: list[str] + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'group_ids': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'ArmIdWrapper'}, + 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'group_ids': {'key': 'properties.groupIds', 'type': '[str]'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + name: Optional[str] = None, + type: Optional[str] = None, + private_endpoint: Optional["ArmIdWrapper"] = None, + private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + **kwargs + ): + """ + :keyword id: Private Endpoint connection resource id. + :paramtype id: str + :keyword name: Private Endpoint Connection Name. + :paramtype name: str + :keyword type: Private Endpoint Connection Resource Type. + :paramtype type: str + :keyword private_endpoint: The resource of private end point. + :paramtype private_endpoint: ~azure.mgmt.apimanagement.models.ArmIdWrapper + :keyword private_link_service_connection_state: A collection of information about the state of + the connection between service consumer and provider. + :paramtype private_link_service_connection_state: + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState + """ + super(RemotePrivateEndpointConnectionWrapper, self).__init__(**kwargs) + self.id = id + self.name = name + self.type = type + self.private_endpoint = private_endpoint + self.private_link_service_connection_state = private_link_service_connection_state + self.provisioning_state = None + self.group_ids = None + + class ReportCollection(msrest.serialization.Model): """Paged Report records list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.ReportRecordContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.ReportRecordContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -10940,6 +15685,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.ReportRecordContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(ReportCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -10951,67 +15704,67 @@ class ReportRecordContract(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name: Name depending on report endpoint specifies product, API, operation or developer + :ivar name: Name depending on report endpoint specifies product, API, operation or developer name. - :type name: str - :param timestamp: Start of aggregation period. The date conforms to the following format: + :vartype name: str + :ivar timestamp: Start of aggregation period. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type timestamp: ~datetime.datetime - :param interval: Length of aggregation period. Interval must be multiple of 15 minutes and may + :vartype timestamp: ~datetime.datetime + :ivar interval: Length of aggregation period. Interval must be multiple of 15 minutes and may not be zero. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations). - :type interval: str - :param country: Country to which this record data is related. - :type country: str - :param region: Country region to which this record data is related. - :type region: str - :param zip: Zip code to which this record data is related. - :type zip: str + :vartype interval: str + :ivar country: Country to which this record data is related. + :vartype country: str + :ivar region: Country region to which this record data is related. + :vartype region: str + :ivar zip: Zip code to which this record data is related. + :vartype zip: str :ivar user_id: User identifier path. /users/{userId}. :vartype user_id: str :ivar product_id: Product identifier path. /products/{productId}. :vartype product_id: str - :param api_id: API identifier path. /apis/{apiId}. - :type api_id: str - :param operation_id: Operation identifier path. /apis/{apiId}/operations/{operationId}. - :type operation_id: str - :param api_region: API region identifier. - :type api_region: str - :param subscription_id: Subscription identifier path. /subscriptions/{subscriptionId}. - :type subscription_id: str - :param call_count_success: Number of successful calls. This includes calls returning + :ivar api_id: API identifier path. /apis/{apiId}. + :vartype api_id: str + :ivar operation_id: Operation identifier path. /apis/{apiId}/operations/{operationId}. + :vartype operation_id: str + :ivar api_region: API region identifier. + :vartype api_region: str + :ivar subscription_id: Subscription identifier path. /subscriptions/{subscriptionId}. + :vartype subscription_id: str + :ivar call_count_success: Number of successful calls. This includes calls returning HttpStatusCode <= 301 and HttpStatusCode.NotModified and HttpStatusCode.TemporaryRedirect. - :type call_count_success: int - :param call_count_blocked: Number of calls blocked due to invalid credentials. This includes + :vartype call_count_success: int + :ivar call_count_blocked: Number of calls blocked due to invalid credentials. This includes calls returning HttpStatusCode.Unauthorized and HttpStatusCode.Forbidden and HttpStatusCode.TooManyRequests. - :type call_count_blocked: int - :param call_count_failed: Number of calls failed due to proxy or backend errors. This includes + :vartype call_count_blocked: int + :ivar call_count_failed: Number of calls failed due to proxy or backend errors. This includes calls returning HttpStatusCode.BadRequest(400) and any Code between HttpStatusCode.InternalServerError (500) and 600. - :type call_count_failed: int - :param call_count_other: Number of other calls. - :type call_count_other: int - :param call_count_total: Total number of calls. - :type call_count_total: int - :param bandwidth: Bandwidth consumed. - :type bandwidth: long - :param cache_hit_count: Number of times when content was served from cache policy. - :type cache_hit_count: int - :param cache_miss_count: Number of times content was fetched from backend. - :type cache_miss_count: int - :param api_time_avg: Average time it took to process request. - :type api_time_avg: float - :param api_time_min: Minimum time it took to process request. - :type api_time_min: float - :param api_time_max: Maximum time it took to process request. - :type api_time_max: float - :param service_time_avg: Average time it took to process request on backend. - :type service_time_avg: float - :param service_time_min: Minimum time it took to process request on backend. - :type service_time_min: float - :param service_time_max: Maximum time it took to process request on backend. - :type service_time_max: float + :vartype call_count_failed: int + :ivar call_count_other: Number of other calls. + :vartype call_count_other: int + :ivar call_count_total: Total number of calls. + :vartype call_count_total: int + :ivar bandwidth: Bandwidth consumed. + :vartype bandwidth: long + :ivar cache_hit_count: Number of times when content was served from cache policy. + :vartype cache_hit_count: int + :ivar cache_miss_count: Number of times content was fetched from backend. + :vartype cache_miss_count: int + :ivar api_time_avg: Average time it took to process request. + :vartype api_time_avg: float + :ivar api_time_min: Minimum time it took to process request. + :vartype api_time_min: float + :ivar api_time_max: Maximum time it took to process request. + :vartype api_time_max: float + :ivar service_time_avg: Average time it took to process request on backend. + :vartype service_time_avg: float + :ivar service_time_min: Minimum time it took to process request on backend. + :vartype service_time_min: float + :ivar service_time_max: Maximum time it took to process request on backend. + :vartype service_time_max: float """ _validation = { @@ -11077,6 +15830,65 @@ def __init__( service_time_max: Optional[float] = None, **kwargs ): + """ + :keyword name: Name depending on report endpoint specifies product, API, operation or developer + name. + :paramtype name: str + :keyword timestamp: Start of aggregation period. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :paramtype timestamp: ~datetime.datetime + :keyword interval: Length of aggregation period. Interval must be multiple of 15 minutes and + may not be zero. The value should be in ISO 8601 format + (http://en.wikipedia.org/wiki/ISO_8601#Durations). + :paramtype interval: str + :keyword country: Country to which this record data is related. + :paramtype country: str + :keyword region: Country region to which this record data is related. + :paramtype region: str + :keyword zip: Zip code to which this record data is related. + :paramtype zip: str + :keyword api_id: API identifier path. /apis/{apiId}. + :paramtype api_id: str + :keyword operation_id: Operation identifier path. /apis/{apiId}/operations/{operationId}. + :paramtype operation_id: str + :keyword api_region: API region identifier. + :paramtype api_region: str + :keyword subscription_id: Subscription identifier path. /subscriptions/{subscriptionId}. + :paramtype subscription_id: str + :keyword call_count_success: Number of successful calls. This includes calls returning + HttpStatusCode <= 301 and HttpStatusCode.NotModified and HttpStatusCode.TemporaryRedirect. + :paramtype call_count_success: int + :keyword call_count_blocked: Number of calls blocked due to invalid credentials. This includes + calls returning HttpStatusCode.Unauthorized and HttpStatusCode.Forbidden and + HttpStatusCode.TooManyRequests. + :paramtype call_count_blocked: int + :keyword call_count_failed: Number of calls failed due to proxy or backend errors. This + includes calls returning HttpStatusCode.BadRequest(400) and any Code between + HttpStatusCode.InternalServerError (500) and 600. + :paramtype call_count_failed: int + :keyword call_count_other: Number of other calls. + :paramtype call_count_other: int + :keyword call_count_total: Total number of calls. + :paramtype call_count_total: int + :keyword bandwidth: Bandwidth consumed. + :paramtype bandwidth: long + :keyword cache_hit_count: Number of times when content was served from cache policy. + :paramtype cache_hit_count: int + :keyword cache_miss_count: Number of times content was fetched from backend. + :paramtype cache_miss_count: int + :keyword api_time_avg: Average time it took to process request. + :paramtype api_time_avg: float + :keyword api_time_min: Minimum time it took to process request. + :paramtype api_time_min: float + :keyword api_time_max: Maximum time it took to process request. + :paramtype api_time_max: float + :keyword service_time_avg: Average time it took to process request on backend. + :paramtype service_time_avg: float + :keyword service_time_min: Minimum time it took to process request on backend. + :paramtype service_time_min: float + :keyword service_time_max: Maximum time it took to process request on backend. + :paramtype service_time_max: float + """ super(ReportRecordContract, self).__init__(**kwargs) self.name = name self.timestamp = timestamp @@ -11111,20 +15923,20 @@ class RepresentationContract(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param content_type: Required. Specifies a registered or custom content type for this + :ivar content_type: Required. Specifies a registered or custom content type for this representation, e.g. application/xml. - :type content_type: str - :param sample: An example of the representation. - :type sample: str - :param schema_id: Schema identifier. Applicable only if 'contentType' value is neither + :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'. - :type schema_id: str - :param type_name: Type name defined by the schema. Applicable only if 'contentType' value is + :vartype schema_id: str + :ivar type_name: Type name defined by the schema. Applicable only if 'contentType' value is neither 'application/x-www-form-urlencoded' nor 'multipart/form-data'. - :type type_name: str - :param form_parameters: Collection of form parameters. Required if 'contentType' value is - either 'application/x-www-form-urlencoded' or 'multipart/form-data'.. - :type form_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :vartype type_name: str + :ivar form_parameters: Collection of form parameters. Required if 'contentType' value is either + 'application/x-www-form-urlencoded' or 'multipart/form-data'.. + :vartype form_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :ivar examples: Exampled defined for the representation. + :vartype examples: dict[str, ~azure.mgmt.apimanagement.models.ParameterExampleContract] """ _validation = { @@ -11133,41 +15945,57 @@ class RepresentationContract(msrest.serialization.Model): _attribute_map = { 'content_type': {'key': 'contentType', 'type': 'str'}, - 'sample': {'key': 'sample', 'type': 'str'}, 'schema_id': {'key': 'schemaId', 'type': 'str'}, 'type_name': {'key': 'typeName', 'type': 'str'}, 'form_parameters': {'key': 'formParameters', 'type': '[ParameterContract]'}, + 'examples': {'key': 'examples', 'type': '{ParameterExampleContract}'}, } def __init__( self, *, content_type: str, - sample: Optional[str] = None, schema_id: Optional[str] = None, type_name: Optional[str] = None, form_parameters: Optional[List["ParameterContract"]] = None, - **kwargs - ): + examples: Optional[Dict[str, "ParameterExampleContract"]] = None, + **kwargs + ): + """ + :keyword content_type: Required. Specifies a registered or custom content type for this + representation, e.g. application/xml. + :paramtype content_type: str + :keyword schema_id: Schema identifier. Applicable only if 'contentType' value is neither + 'application/x-www-form-urlencoded' nor 'multipart/form-data'. + :paramtype schema_id: str + :keyword type_name: Type name defined by the schema. Applicable only if 'contentType' value is + neither 'application/x-www-form-urlencoded' nor 'multipart/form-data'. + :paramtype type_name: str + :keyword form_parameters: Collection of form parameters. Required if 'contentType' value is + either 'application/x-www-form-urlencoded' or 'multipart/form-data'.. + :paramtype form_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :keyword examples: Exampled defined for the representation. + :paramtype examples: dict[str, ~azure.mgmt.apimanagement.models.ParameterExampleContract] + """ super(RepresentationContract, self).__init__(**kwargs) self.content_type = content_type - self.sample = sample self.schema_id = schema_id self.type_name = type_name self.form_parameters = form_parameters + self.examples = examples class RequestContract(msrest.serialization.Model): """Operation request details. - :param description: Operation request description. - :type description: str - :param query_parameters: Collection of operation request query parameters. - :type query_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :param headers: Collection of operation request headers. - :type headers: list[~azure.mgmt.apimanagement.models.ParameterContract] - :param representations: Collection of operation request representations. - :type representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] + :ivar description: Operation request description. + :vartype description: str + :ivar query_parameters: Collection of operation request query parameters. + :vartype query_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :ivar headers: Collection of operation request headers. + :vartype headers: list[~azure.mgmt.apimanagement.models.ParameterContract] + :ivar representations: Collection of operation request representations. + :vartype representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] """ _attribute_map = { @@ -11186,6 +16014,16 @@ def __init__( representations: Optional[List["RepresentationContract"]] = None, **kwargs ): + """ + :keyword description: Operation request description. + :paramtype description: str + :keyword query_parameters: Collection of operation request query parameters. + :paramtype query_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :keyword headers: Collection of operation request headers. + :paramtype headers: list[~azure.mgmt.apimanagement.models.ParameterContract] + :keyword representations: Collection of operation request representations. + :paramtype representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] + """ super(RequestContract, self).__init__(**kwargs) self.description = description self.query_parameters = query_parameters @@ -11196,10 +16034,10 @@ def __init__( class RequestReportCollection(msrest.serialization.Model): """Paged Report records list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.RequestReportRecordContract] - :param count: Total record count number across all pages. - :type count: long + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.RequestReportRecordContract] + :ivar count: Total record count number across all pages. + :vartype count: long """ _attribute_map = { @@ -11214,6 +16052,12 @@ def __init__( count: Optional[int] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.RequestReportRecordContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + """ super(RequestReportCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -11224,48 +16068,48 @@ class RequestReportRecordContract(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param api_id: API identifier path. /apis/{apiId}. - :type api_id: str - :param operation_id: Operation identifier path. /apis/{apiId}/operations/{operationId}. - :type operation_id: str + :ivar api_id: API identifier path. /apis/{apiId}. + :vartype api_id: str + :ivar operation_id: Operation identifier path. /apis/{apiId}/operations/{operationId}. + :vartype operation_id: str :ivar product_id: Product identifier path. /products/{productId}. :vartype product_id: str :ivar user_id: User identifier path. /users/{userId}. :vartype user_id: str - :param method: The HTTP method associated with this request.. - :type method: str - :param url: The full URL associated with this request. - :type url: str - :param ip_address: The client IP address associated with this request. - :type ip_address: str - :param backend_response_code: The HTTP status code received by the gateway as a result of + :ivar method: The HTTP method associated with this request.. + :vartype method: str + :ivar url: The full URL associated with this request. + :vartype url: str + :ivar ip_address: The client IP address associated with this request. + :vartype ip_address: str + :ivar backend_response_code: The HTTP status code received by the gateway as a result of forwarding this request to the backend. - :type backend_response_code: str - :param response_code: The HTTP status code returned by the gateway. - :type response_code: int - :param response_size: The size of the response returned by the gateway. - :type response_size: int - :param timestamp: The date and time when this request was received by the gateway in ISO 8601 + :vartype backend_response_code: str + :ivar response_code: The HTTP status code returned by the gateway. + :vartype response_code: int + :ivar response_size: The size of the response returned by the gateway. + :vartype response_size: int + :ivar timestamp: The date and time when this request was received by the gateway in ISO 8601 format. - :type timestamp: ~datetime.datetime - :param cache: Specifies if response cache was involved in generating the response. If the value + :vartype timestamp: ~datetime.datetime + :ivar cache: Specifies if response cache was involved in generating the response. If the value is none, the cache was not used. If the value is hit, cached response was returned. If the value is miss, the cache was used but lookup resulted in a miss and request was fulfilled by the backend. - :type cache: str - :param api_time: The total time it took to process this request. - :type api_time: float - :param service_time: he time it took to forward this request to the backend and get the - response back. - :type service_time: float - :param api_region: Azure region where the gateway that processed this request is located. - :type api_region: str - :param subscription_id: Subscription identifier path. /subscriptions/{subscriptionId}. - :type subscription_id: str - :param request_id: Request Identifier. - :type request_id: str - :param request_size: The size of this request.. - :type request_size: int + :vartype cache: str + :ivar api_time: The total time it took to process this request. + :vartype api_time: float + :ivar service_time: he time it took to forward this request to the backend and get the response + back. + :vartype service_time: float + :ivar api_region: Azure region where the gateway that processed this request is located. + :vartype api_region: str + :ivar subscription_id: Subscription identifier path. /subscriptions/{subscriptionId}. + :vartype subscription_id: str + :ivar request_id: Request Identifier. + :vartype request_id: str + :ivar request_size: The size of this request.. + :vartype request_size: int """ _validation = { @@ -11315,6 +16159,46 @@ def __init__( request_size: Optional[int] = None, **kwargs ): + """ + :keyword api_id: API identifier path. /apis/{apiId}. + :paramtype api_id: str + :keyword operation_id: Operation identifier path. /apis/{apiId}/operations/{operationId}. + :paramtype operation_id: str + :keyword method: The HTTP method associated with this request.. + :paramtype method: str + :keyword url: The full URL associated with this request. + :paramtype url: str + :keyword ip_address: The client IP address associated with this request. + :paramtype ip_address: str + :keyword backend_response_code: The HTTP status code received by the gateway as a result of + forwarding this request to the backend. + :paramtype backend_response_code: str + :keyword response_code: The HTTP status code returned by the gateway. + :paramtype response_code: int + :keyword response_size: The size of the response returned by the gateway. + :paramtype response_size: int + :keyword timestamp: The date and time when this request was received by the gateway in ISO 8601 + format. + :paramtype timestamp: ~datetime.datetime + :keyword cache: Specifies if response cache was involved in generating the response. If the + value is none, the cache was not used. If the value is hit, cached response was returned. If + the value is miss, the cache was used but lookup resulted in a miss and request was fulfilled + by the backend. + :paramtype cache: str + :keyword api_time: The total time it took to process this request. + :paramtype api_time: float + :keyword service_time: he time it took to forward this request to the backend and get the + response back. + :paramtype service_time: float + :keyword api_region: Azure region where the gateway that processed this request is located. + :paramtype api_region: str + :keyword subscription_id: Subscription identifier path. /subscriptions/{subscriptionId}. + :paramtype subscription_id: str + :keyword request_id: Request Identifier. + :paramtype request_id: str + :keyword request_size: The size of this request.. + :paramtype request_size: int + """ super(RequestReportRecordContract, self).__init__(**kwargs) self.api_id = api_id self.operation_id = operation_id @@ -11341,14 +16225,14 @@ class ResourceLocationDataContract(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. A canonical name for the geographic or physical location. - :type name: str - :param city: The city or locality where the resource is located. - :type city: str - :param district: The district, state, or province where the resource is located. - :type district: str - :param country_or_region: The country or region where the resource is located. - :type country_or_region: str + :ivar name: Required. A canonical name for the geographic or physical location. + :vartype name: str + :ivar city: The city or locality where the resource is located. + :vartype city: str + :ivar district: The district, state, or province where the resource is located. + :vartype district: str + :ivar country_or_region: The country or region where the resource is located. + :vartype country_or_region: str """ _validation = { @@ -11374,6 +16258,16 @@ def __init__( country_or_region: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. A canonical name for the geographic or physical location. + :paramtype name: str + :keyword city: The city or locality where the resource is located. + :paramtype city: str + :keyword district: The district, state, or province where the resource is located. + :paramtype district: str + :keyword country_or_region: The country or region where the resource is located. + :paramtype country_or_region: str + """ super(ResourceLocationDataContract, self).__init__(**kwargs) self.name = name self.city = city @@ -11384,9 +16278,9 @@ def __init__( class ResourceSku(msrest.serialization.Model): """Describes an available API Management SKU. - :param name: Name of the Sku. Possible values include: "Developer", "Standard", "Premium", + :ivar name: Name of the Sku. Possible values include: "Developer", "Standard", "Premium", "Basic", "Consumption", "Isolated". - :type name: str or ~azure.mgmt.apimanagement.models.SkuType + :vartype name: str or ~azure.mgmt.apimanagement.models.SkuType """ _attribute_map = { @@ -11399,6 +16293,11 @@ def __init__( name: Optional[Union[str, "SkuType"]] = None, **kwargs ): + """ + :keyword name: Name of the Sku. Possible values include: "Developer", "Standard", "Premium", + "Basic", "Consumption", "Isolated". + :paramtype name: str or ~azure.mgmt.apimanagement.models.SkuType + """ super(ResourceSku, self).__init__(**kwargs) self.name = name @@ -11437,6 +16336,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceSkuCapacity, self).__init__(**kwargs) self.minimum = None self.maximum = None @@ -11473,6 +16374,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceSkuResult, self).__init__(**kwargs) self.resource_type = None self.sku = None @@ -11484,10 +16387,10 @@ class ResourceSkuResults(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. The list of skus available for the service. - :type value: list[~azure.mgmt.apimanagement.models.ResourceSkuResult] - :param next_link: The uri to fetch the next page of API Management service Skus. - :type next_link: str + :ivar value: Required. The list of skus available for the service. + :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 = { @@ -11506,6 +16409,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. The list of skus available for the service. + :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) self.value = value self.next_link = next_link @@ -11516,14 +16425,14 @@ class ResponseContract(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param status_code: Required. Operation response HTTP status code. - :type status_code: int - :param description: Operation response description. - :type description: str - :param representations: Collection of operation response representations. - :type representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] - :param headers: Collection of operation response headers. - :type headers: list[~azure.mgmt.apimanagement.models.ParameterContract] + :ivar status_code: Required. Operation response HTTP status code. + :vartype status_code: int + :ivar description: Operation response description. + :vartype description: str + :ivar representations: Collection of operation response representations. + :vartype representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] + :ivar headers: Collection of operation response headers. + :vartype headers: list[~azure.mgmt.apimanagement.models.ParameterContract] """ _validation = { @@ -11546,6 +16455,16 @@ def __init__( headers: Optional[List["ParameterContract"]] = None, **kwargs ): + """ + :keyword status_code: Required. Operation response HTTP status code. + :paramtype status_code: int + :keyword description: Operation response description. + :paramtype description: str + :keyword representations: Collection of operation response representations. + :paramtype representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] + :keyword headers: Collection of operation response headers. + :paramtype headers: list[~azure.mgmt.apimanagement.models.ParameterContract] + """ super(ResponseContract, self).__init__(**kwargs) self.status_code = status_code self.description = description @@ -11556,10 +16475,10 @@ def __init__( class SamplingSettings(msrest.serialization.Model): """Sampling settings for Diagnostic. - :param sampling_type: Sampling type. Possible values include: "fixed". - :type sampling_type: str or ~azure.mgmt.apimanagement.models.SamplingType - :param percentage: Rate of sampling for fixed-rate sampling. - :type percentage: float + :ivar sampling_type: Sampling type. Possible values include: "fixed". + :vartype sampling_type: str or ~azure.mgmt.apimanagement.models.SamplingType + :ivar percentage: Rate of sampling for fixed-rate sampling. + :vartype percentage: float """ _validation = { @@ -11578,6 +16497,12 @@ def __init__( percentage: Optional[float] = None, **kwargs ): + """ + :keyword sampling_type: Sampling type. Possible values include: "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) self.sampling_type = sampling_type self.percentage = percentage @@ -11586,12 +16511,11 @@ def __init__( class SaveConfigurationParameter(msrest.serialization.Model): """Save Tenant Configuration Contract details. - :param branch: The name of the Git branch in which to commit the current configuration - snapshot. - :type branch: str - :param force: The value if true, the current configuration database is committed to the Git + :ivar branch: The name of the Git branch in which to commit the current configuration snapshot. + :vartype branch: str + :ivar force: The value if true, the current configuration database is committed to the Git repository, even if the Git repository has newer changes that would be overwritten. - :type force: bool + :vartype force: bool """ _attribute_map = { @@ -11606,6 +16530,14 @@ def __init__( force: Optional[bool] = None, **kwargs ): + """ + :keyword branch: The name of the Git branch in which to commit the current configuration + snapshot. + :paramtype branch: str + :keyword force: The value if true, the current configuration database is committed to the Git + repository, even if the Git repository has newer changes that would be overwritten. + :paramtype force: bool + """ super(SaveConfigurationParameter, self).__init__(**kwargs) self.branch = branch self.force = force @@ -11616,10 +16548,10 @@ class SchemaCollection(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: Api Schema Contract value. + :ivar value: API Schema Contract value. :vartype value: list[~azure.mgmt.apimanagement.models.SchemaContract] - :param count: Total record count number. - :type count: long + :ivar count: Total record count number. + :vartype count: long :ivar next_link: Next page link if any. :vartype next_link: str """ @@ -11641,6 +16573,10 @@ def __init__( count: Optional[int] = None, **kwargs ): + """ + :keyword count: Total record count number. + :paramtype count: long + """ super(SchemaCollection, self).__init__(**kwargs) self.value = None self.count = count @@ -11648,28 +16584,33 @@ def __init__( class SchemaContract(Resource): - """Schema Contract details. + """API Schema Contract details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param content_type: Must be a valid a media type used in a Content-Type header as defined in + :ivar content_type: Must be a valid a media type used in a Content-Type header as defined in the RFC 2616. Media type of the schema document (e.g. application/json, application/xml).
- ``Swagger`` Schema use ``application/vnd.ms-azure-apim.swagger.definitions+json``
- ``WSDL`` Schema use ``application/vnd.ms-azure-apim.xsd+xml``
- ``OpenApi`` Schema use ``application/vnd.oai.openapi.components+json``
- ``WADL Schema`` use ``application/vnd.ms-azure-apim.wadl.grammars+xml``. - :type content_type: str - :param value: Json escaped string defining the document representing the Schema. Used for + :vartype content_type: str + :ivar value: Json escaped string defining the document representing the Schema. Used for schemas other than Swagger/OpenAPI. - :type value: str - :param definitions: Types definitions. Used for Swagger/OpenAPI schemas only, null otherwise. - :type definitions: any + :vartype value: str + :ivar definitions: Types definitions. Used for Swagger/OpenAPI v1 schemas only, null otherwise. + :vartype definitions: any + :ivar components: Types definitions. Used for Swagger/OpenAPI v2/v3 schemas only, null + otherwise. + :vartype components: any """ _validation = { @@ -11685,6 +16626,7 @@ class SchemaContract(Resource): '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__( @@ -11693,23 +16635,43 @@ def __init__( content_type: Optional[str] = None, value: Optional[str] = None, definitions: Optional[Any] = None, - **kwargs - ): + components: Optional[Any] = None, + **kwargs + ): + """ + :keyword content_type: Must be a valid a media type used in a Content-Type header as defined in + the RFC 2616. Media type of the schema document (e.g. application/json, application/xml).
+ - ``Swagger`` Schema use ``application/vnd.ms-azure-apim.swagger.definitions+json``
- + ``WSDL`` Schema use ``application/vnd.ms-azure-apim.xsd+xml``
- ``OpenApi`` Schema use + ``application/vnd.oai.openapi.components+json``
- ``WADL Schema`` use + ``application/vnd.ms-azure-apim.wadl.grammars+xml``. + :paramtype content_type: str + :keyword value: Json escaped string defining the document representing the Schema. Used for + schemas other than Swagger/OpenAPI. + :paramtype value: str + :keyword definitions: Types definitions. Used for Swagger/OpenAPI v1 schemas only, null + otherwise. + :paramtype definitions: any + :keyword components: Types definitions. Used for Swagger/OpenAPI v2/v3 schemas only, null + otherwise. + :paramtype components: any + """ super(SchemaContract, self).__init__(**kwargs) self.content_type = content_type self.value = value self.definitions = definitions + self.components = components class SubscriptionCollection(msrest.serialization.Model): """Paged Subscriptions list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.SubscriptionContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.SubscriptionContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -11726,6 +16688,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.SubscriptionContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(SubscriptionCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -11737,20 +16707,22 @@ class SubscriptionContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param owner_id: The user resource identifier of the subscription owner. The value is a valid + :ivar owner_id: The user resource identifier of the subscription owner. The value is a valid relative URL in the format of /users/{userId} where {userId} is a user identifier. - :type owner_id: str - :param scope: Scope like /products/{productId} or /apis or /apis/{apiId}. - :type scope: str - :param display_name: The name of the subscription, or null if the subscription has no name. - :type display_name: str - :param state: Subscription state. Possible states are * active – the subscription is active, * + :vartype owner_id: str + :ivar scope: Scope like /products/{productId} or /apis or /apis/{apiId}. + :vartype scope: str + :ivar display_name: The name of the subscription, or null if the subscription has no name. + :vartype display_name: str + :ivar state: Subscription state. Possible states are * active – the subscription is active, * suspended – the subscription is blocked, and the subscriber cannot call any APIs of the product, * submitted – the subscription request has been made by the developer, but has not yet been approved or rejected, * rejected – the subscription request has been denied by an @@ -11758,39 +16730,39 @@ class SubscriptionContract(Resource): administrator, * expired – the subscription reached its expiration date and was deactivated. Possible values include: "suspended", "active", "expired", "submitted", "rejected", "cancelled". - :type state: str or ~azure.mgmt.apimanagement.models.SubscriptionState + :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 - :param start_date: Subscription activation date. The setting is for audit purposes only and the + :ivar start_date: Subscription activation date. The setting is for audit purposes only and the subscription is not automatically activated. The subscription lifecycle can be managed by using the ``state`` property. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type start_date: ~datetime.datetime - :param expiration_date: Subscription expiration date. The setting is for audit purposes only - and the subscription is not automatically expired. The subscription lifecycle can be managed by + :vartype start_date: ~datetime.datetime + :ivar expiration_date: Subscription expiration date. The setting is for audit purposes only and + the subscription is not automatically expired. The subscription lifecycle can be managed by using the ``state`` property. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type expiration_date: ~datetime.datetime - :param end_date: Date when subscription was cancelled or expired. The setting is for audit + :vartype expiration_date: ~datetime.datetime + :ivar end_date: Date when subscription was cancelled or expired. The setting is for audit purposes only and the subscription is not automatically cancelled. The subscription lifecycle can be managed by using the ``state`` property. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type end_date: ~datetime.datetime - :param notification_date: Upcoming subscription expiration notification date. The date conforms + :vartype end_date: ~datetime.datetime + :ivar notification_date: Upcoming subscription expiration notification date. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type notification_date: ~datetime.datetime - :param primary_key: Subscription primary key. This property will not be filled on 'GET' + :vartype notification_date: ~datetime.datetime + :ivar primary_key: Subscription primary key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. - :type primary_key: str - :param secondary_key: Subscription secondary key. This property will not be filled on 'GET' + :vartype primary_key: str + :ivar secondary_key: Subscription secondary key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. - :type secondary_key: str - :param state_comment: Optional subscription comment added by an administrator when the state is + :vartype secondary_key: str + :ivar state_comment: Optional subscription comment added by an administrator when the state is changed to the 'rejected'. - :type state_comment: str - :param allow_tracing: Determines whether tracing is enabled. - :type allow_tracing: bool + :vartype state_comment: str + :ivar allow_tracing: Determines whether tracing is enabled. + :vartype allow_tracing: bool """ _validation = { @@ -11839,6 +16811,54 @@ def __init__( allow_tracing: Optional[bool] = None, **kwargs ): + """ + :keyword owner_id: The user resource identifier of the subscription owner. The value is a valid + relative URL in the format of /users/{userId} where {userId} is a user identifier. + :paramtype owner_id: str + :keyword scope: Scope like /products/{productId} or /apis or /apis/{apiId}. + :paramtype scope: str + :keyword display_name: The name of the subscription, or null if the subscription has no name. + :paramtype display_name: str + :keyword state: Subscription state. Possible states are * active – the subscription is active, + * suspended – the subscription is blocked, and the subscriber cannot call any APIs of the + product, * submitted – the subscription request has been made by the developer, but has not yet + been approved or rejected, * rejected – the subscription request has been denied by an + administrator, * cancelled – the subscription has been cancelled by the developer or + administrator, * expired – the subscription reached its expiration date and was deactivated. + Possible values include: "suspended", "active", "expired", "submitted", "rejected", + "cancelled". + :paramtype state: str or ~azure.mgmt.apimanagement.models.SubscriptionState + :keyword start_date: Subscription activation date. The setting is for audit purposes only and + the subscription is not automatically activated. The subscription lifecycle can be managed by + using the ``state`` property. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :paramtype start_date: ~datetime.datetime + :keyword expiration_date: Subscription expiration date. The setting is for audit purposes only + and the subscription is not automatically expired. The subscription lifecycle can be managed by + using the ``state`` property. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :paramtype expiration_date: ~datetime.datetime + :keyword end_date: Date when subscription was cancelled or expired. The setting is for audit + purposes only and the subscription is not automatically cancelled. The subscription lifecycle + can be managed by using the ``state`` property. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :paramtype end_date: ~datetime.datetime + :keyword notification_date: Upcoming subscription expiration notification date. The date + conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 + standard. + :paramtype notification_date: ~datetime.datetime + :keyword primary_key: Subscription primary key. This property will not be filled on 'GET' + operations! Use '/listSecrets' POST request to get the value. + :paramtype primary_key: str + :keyword secondary_key: Subscription secondary key. This property will not be filled on 'GET' + operations! Use '/listSecrets' POST request to get the value. + :paramtype secondary_key: str + :keyword state_comment: Optional subscription comment added by an administrator when the state + is changed to the 'rejected'. + :paramtype state_comment: str + :keyword allow_tracing: Determines whether tracing is enabled. + :paramtype allow_tracing: bool + """ super(SubscriptionContract, self).__init__(**kwargs) self.owner_id = owner_id self.scope = scope @@ -11858,31 +16878,30 @@ def __init__( class SubscriptionCreateParameters(msrest.serialization.Model): """Subscription create details. - :param owner_id: User (user id path) for whom subscription is being created in form + :ivar owner_id: User (user id path) for whom subscription is being created in form /users/{userId}. - :type owner_id: str - :param scope: Scope like /products/{productId} or /apis or /apis/{apiId}. - :type scope: str - :param display_name: Subscription name. - :type display_name: str - :param primary_key: Primary subscription key. If not specified during request key will be + :vartype owner_id: str + :ivar scope: Scope like /products/{productId} or /apis or /apis/{apiId}. + :vartype scope: str + :ivar display_name: Subscription name. + :vartype display_name: str + :ivar primary_key: Primary subscription key. If not specified during request key will be generated automatically. - :type primary_key: str - :param secondary_key: Secondary subscription key. If not specified during request key will be + :vartype primary_key: str + :ivar secondary_key: Secondary subscription key. If not specified during request key will be generated automatically. - :type secondary_key: str - :param state: Initial subscription state. If no value is specified, subscription is created - with Submitted state. Possible states are * active – the subscription is active, * suspended – - the subscription is blocked, and the subscriber cannot call any APIs of the product, * - submitted – the subscription request has been made by the developer, but has not yet been - approved or rejected, * rejected – the subscription request has been denied by an - administrator, * cancelled – the subscription has been cancelled by the developer or - administrator, * expired – the subscription reached its expiration date and was deactivated. - Possible values include: "suspended", "active", "expired", "submitted", "rejected", - "cancelled". - :type state: str or ~azure.mgmt.apimanagement.models.SubscriptionState - :param allow_tracing: Determines whether tracing can be enabled. - :type allow_tracing: bool + :vartype secondary_key: str + :ivar state: Initial subscription state. If no value is specified, subscription is created with + Submitted state. Possible states are * active – the subscription is active, * suspended – the + subscription is blocked, and the subscriber cannot call any APIs of the product, * submitted – + the subscription request has been made by the developer, but has not yet been approved or + rejected, * rejected – the subscription request has been denied by an administrator, * + cancelled – the subscription has been cancelled by the developer or administrator, * expired – + the subscription reached its expiration date and was deactivated. Possible values include: + "suspended", "active", "expired", "submitted", "rejected", "cancelled". + :vartype state: str or ~azure.mgmt.apimanagement.models.SubscriptionState + :ivar allow_tracing: Determines whether tracing can be enabled. + :vartype allow_tracing: bool """ _validation = { @@ -11913,6 +16932,33 @@ def __init__( allow_tracing: Optional[bool] = None, **kwargs ): + """ + :keyword owner_id: User (user id path) for whom subscription is being created in form + /users/{userId}. + :paramtype owner_id: str + :keyword scope: Scope like /products/{productId} or /apis or /apis/{apiId}. + :paramtype scope: str + :keyword display_name: Subscription name. + :paramtype display_name: str + :keyword primary_key: Primary subscription key. If not specified during request key will be + generated automatically. + :paramtype primary_key: str + :keyword secondary_key: Secondary subscription key. If not specified during request key will be + generated automatically. + :paramtype secondary_key: str + :keyword state: Initial subscription state. If no value is specified, subscription is created + with Submitted state. Possible states are * active – the subscription is active, * suspended – + the subscription is blocked, and the subscriber cannot call any APIs of the product, * + submitted – the subscription request has been made by the developer, but has not yet been + approved or rejected, * rejected – the subscription request has been denied by an + administrator, * cancelled – the subscription has been cancelled by the developer or + administrator, * expired – the subscription reached its expiration date and was deactivated. + Possible values include: "suspended", "active", "expired", "submitted", "rejected", + "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) self.owner_id = owner_id self.scope = scope @@ -11926,10 +16972,10 @@ def __init__( class SubscriptionKeyParameterNamesContract(msrest.serialization.Model): """Subscription key parameter names details. - :param header: Subscription key header name. - :type header: str - :param query: Subscription key query string parameter name. - :type query: str + :ivar header: Subscription key header name. + :vartype header: str + :ivar query: Subscription key query string parameter name. + :vartype query: str """ _attribute_map = { @@ -11944,6 +16990,12 @@ def __init__( 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) self.header = header self.query = query @@ -11952,10 +17004,10 @@ def __init__( class SubscriptionKeysContract(msrest.serialization.Model): """Subscription keys. - :param primary_key: Subscription primary key. - :type primary_key: str - :param secondary_key: Subscription secondary key. - :type secondary_key: str + :ivar primary_key: Subscription primary key. + :vartype primary_key: str + :ivar secondary_key: Subscription secondary key. + :vartype secondary_key: str """ _validation = { @@ -11975,6 +17027,12 @@ def __init__( 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) self.primary_key = primary_key self.secondary_key = secondary_key @@ -11983,8 +17041,8 @@ def __init__( class SubscriptionsDelegationSettingsProperties(msrest.serialization.Model): """Subscriptions delegation settings properties. - :param enabled: Enable or disable delegation for subscriptions. - :type enabled: bool + :ivar enabled: Enable or disable delegation for subscriptions. + :vartype enabled: bool """ _attribute_map = { @@ -11997,6 +17055,10 @@ def __init__( enabled: Optional[bool] = None, **kwargs ): + """ + :keyword enabled: Enable or disable delegation for subscriptions. + :paramtype enabled: bool + """ super(SubscriptionsDelegationSettingsProperties, self).__init__(**kwargs) self.enabled = enabled @@ -12004,22 +17066,22 @@ def __init__( class SubscriptionUpdateParameters(msrest.serialization.Model): """Subscription update details. - :param owner_id: User identifier path: /users/{userId}. - :type owner_id: str - :param scope: Scope like /products/{productId} or /apis or /apis/{apiId}. - :type scope: str - :param expiration_date: Subscription expiration date. The setting is for audit purposes only - and the subscription is not automatically expired. The subscription lifecycle can be managed by + :ivar owner_id: User identifier path: /users/{userId}. + :vartype owner_id: str + :ivar scope: Scope like /products/{productId} or /apis or /apis/{apiId}. + :vartype scope: str + :ivar expiration_date: Subscription expiration date. The setting is for audit purposes only and + the subscription is not automatically expired. The subscription lifecycle can be managed by using the ``state`` property. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type expiration_date: ~datetime.datetime - :param display_name: Subscription name. - :type display_name: str - :param primary_key: Primary subscription key. - :type primary_key: str - :param secondary_key: Secondary subscription key. - :type secondary_key: str - :param state: Subscription state. Possible states are * active – the subscription is active, * + :vartype expiration_date: ~datetime.datetime + :ivar display_name: Subscription name. + :vartype display_name: str + :ivar primary_key: Primary subscription key. + :vartype primary_key: str + :ivar secondary_key: Secondary subscription key. + :vartype secondary_key: str + :ivar state: Subscription state. Possible states are * active – the subscription is active, * suspended – the subscription is blocked, and the subscriber cannot call any APIs of the product, * submitted – the subscription request has been made by the developer, but has not yet been approved or rejected, * rejected – the subscription request has been denied by an @@ -12027,12 +17089,12 @@ class SubscriptionUpdateParameters(msrest.serialization.Model): administrator, * expired – the subscription reached its expiration date and was deactivated. Possible values include: "suspended", "active", "expired", "submitted", "rejected", "cancelled". - :type state: str or ~azure.mgmt.apimanagement.models.SubscriptionState - :param state_comment: Comments describing subscription state change by the administrator when + :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'. - :type state_comment: str - :param allow_tracing: Determines whether tracing can be enabled. - :type allow_tracing: bool + :vartype state_comment: str + :ivar allow_tracing: Determines whether tracing can be enabled. + :vartype allow_tracing: bool """ _validation = { @@ -12066,6 +17128,37 @@ def __init__( allow_tracing: Optional[bool] = None, **kwargs ): + """ + :keyword owner_id: User identifier path: /users/{userId}. + :paramtype owner_id: str + :keyword scope: Scope like /products/{productId} or /apis or /apis/{apiId}. + :paramtype scope: str + :keyword expiration_date: Subscription expiration date. The setting is for audit purposes only + and the subscription is not automatically expired. The subscription lifecycle can be managed by + using the ``state`` property. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :paramtype expiration_date: ~datetime.datetime + :keyword display_name: Subscription name. + :paramtype display_name: str + :keyword primary_key: Primary subscription key. + :paramtype primary_key: str + :keyword secondary_key: Secondary subscription key. + :paramtype secondary_key: str + :keyword state: Subscription state. Possible states are * active – the subscription is active, + * suspended – the subscription is blocked, and the subscriber cannot call any APIs of the + product, * submitted – the subscription request has been made by the developer, but has not yet + been approved or rejected, * rejected – the subscription request has been denied by an + administrator, * cancelled – the subscription has been cancelled by the developer or + administrator, * expired – the subscription reached its expiration date and was deactivated. + Possible values include: "suspended", "active", "expired", "submitted", "rejected", + "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) self.owner_id = owner_id self.scope = scope @@ -12078,15 +17171,79 @@ def __init__( self.allow_tracing = allow_tracing +class SystemData(msrest.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 ~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 ~azure.mgmt.apimanagement.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "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_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 ~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 ~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) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + class TagCollection(msrest.serialization.Model): """Paged Tag list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.TagContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.TagContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -12103,6 +17260,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.TagContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(TagCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -12114,14 +17279,16 @@ class TagContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param display_name: Tag name. - :type display_name: str + :ivar display_name: Tag name. + :vartype display_name: str """ _validation = { @@ -12144,6 +17311,10 @@ def __init__( display_name: Optional[str] = None, **kwargs ): + """ + :keyword display_name: Tag name. + :paramtype display_name: str + """ super(TagContract, self).__init__(**kwargs) self.display_name = display_name @@ -12151,8 +17322,8 @@ def __init__( class TagCreateUpdateParameters(msrest.serialization.Model): """Parameters supplied to Create/Update Tag operations. - :param display_name: Tag name. - :type display_name: str + :ivar display_name: Tag name. + :vartype display_name: str """ _validation = { @@ -12169,6 +17340,10 @@ def __init__( display_name: Optional[str] = None, **kwargs ): + """ + :keyword display_name: Tag name. + :paramtype display_name: str + """ super(TagCreateUpdateParameters, self).__init__(**kwargs) self.display_name = display_name @@ -12176,12 +17351,12 @@ def __init__( class TagDescriptionBaseProperties(msrest.serialization.Model): """Parameters supplied to the Create TagDescription operation. - :param description: Description of the Tag. - :type description: str - :param external_docs_url: Absolute URL of external resources describing the tag. - :type external_docs_url: str - :param external_docs_description: Description of the external resources describing the tag. - :type external_docs_description: str + :ivar description: Description of the Tag. + :vartype description: str + :ivar external_docs_url: Absolute URL of external resources describing the tag. + :vartype external_docs_url: str + :ivar external_docs_description: Description of the external resources describing the tag. + :vartype external_docs_description: str """ _validation = { @@ -12202,6 +17377,14 @@ def __init__( external_docs_description: Optional[str] = None, **kwargs ): + """ + :keyword description: Description of the Tag. + :paramtype description: str + :keyword external_docs_url: Absolute URL of external resources describing the tag. + :paramtype external_docs_url: str + :keyword external_docs_description: Description of the external resources describing the tag. + :paramtype external_docs_description: str + """ super(TagDescriptionBaseProperties, self).__init__(**kwargs) self.description = description self.external_docs_url = external_docs_url @@ -12211,12 +17394,12 @@ def __init__( class TagDescriptionCollection(msrest.serialization.Model): """Paged TagDescription list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.TagDescriptionContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.TagDescriptionContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -12233,6 +17416,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.TagDescriptionContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(TagDescriptionCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -12244,22 +17435,24 @@ class TagDescriptionContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param description: Description of the Tag. - :type description: str - :param external_docs_url: Absolute URL of external resources describing the tag. - :type external_docs_url: str - :param external_docs_description: Description of the external resources describing the tag. - :type external_docs_description: str - :param tag_id: Identifier of the tag in the form of /tags/{tagId}. - :type tag_id: str - :param display_name: Tag name. - :type display_name: str + :ivar description: Description of the Tag. + :vartype description: str + :ivar external_docs_url: Absolute URL of external resources describing the tag. + :vartype external_docs_url: str + :ivar external_docs_description: Description of the external resources describing the tag. + :vartype external_docs_description: str + :ivar tag_id: Identifier of the tag in the form of /tags/{tagId}. + :vartype tag_id: str + :ivar display_name: Tag name. + :vartype display_name: str """ _validation = { @@ -12291,6 +17484,18 @@ def __init__( display_name: Optional[str] = None, **kwargs ): + """ + :keyword description: Description of the Tag. + :paramtype description: str + :keyword external_docs_url: Absolute URL of external resources describing the tag. + :paramtype external_docs_url: str + :keyword external_docs_description: Description of the external resources describing the tag. + :paramtype external_docs_description: str + :keyword tag_id: Identifier of the tag in the form of /tags/{tagId}. + :paramtype tag_id: str + :keyword display_name: Tag name. + :paramtype display_name: str + """ super(TagDescriptionContract, self).__init__(**kwargs) self.description = description self.external_docs_url = external_docs_url @@ -12302,16 +17507,16 @@ def __init__( class TagDescriptionContractProperties(TagDescriptionBaseProperties): """TagDescription contract Properties. - :param description: Description of the Tag. - :type description: str - :param external_docs_url: Absolute URL of external resources describing the tag. - :type external_docs_url: str - :param external_docs_description: Description of the external resources describing the tag. - :type external_docs_description: str - :param tag_id: Identifier of the tag in the form of /tags/{tagId}. - :type tag_id: str - :param display_name: Tag name. - :type display_name: str + :ivar description: Description of the Tag. + :vartype description: str + :ivar external_docs_url: Absolute URL of external resources describing the tag. + :vartype external_docs_url: str + :ivar external_docs_description: Description of the external resources describing the tag. + :vartype external_docs_description: str + :ivar tag_id: Identifier of the tag in the form of /tags/{tagId}. + :vartype tag_id: str + :ivar display_name: Tag name. + :vartype display_name: str """ _validation = { @@ -12337,6 +17542,18 @@ def __init__( display_name: Optional[str] = None, **kwargs ): + """ + :keyword description: Description of the Tag. + :paramtype description: str + :keyword external_docs_url: Absolute URL of external resources describing the tag. + :paramtype external_docs_url: str + :keyword external_docs_description: Description of the external resources describing the tag. + :paramtype external_docs_description: str + :keyword tag_id: Identifier of the tag in the form of /tags/{tagId}. + :paramtype tag_id: str + :keyword display_name: Tag name. + :paramtype display_name: str + """ super(TagDescriptionContractProperties, self).__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 @@ -12345,12 +17562,12 @@ def __init__( class TagDescriptionCreateParameters(msrest.serialization.Model): """Parameters supplied to the Create TagDescription operation. - :param description: Description of the Tag. - :type description: str - :param external_docs_url: Absolute URL of external resources describing the tag. - :type external_docs_url: str - :param external_docs_description: Description of the external resources describing the tag. - :type external_docs_description: str + :ivar description: Description of the Tag. + :vartype description: str + :ivar external_docs_url: Absolute URL of external resources describing the tag. + :vartype external_docs_url: str + :ivar external_docs_description: Description of the external resources describing the tag. + :vartype external_docs_description: str """ _validation = { @@ -12371,6 +17588,14 @@ def __init__( external_docs_description: Optional[str] = None, **kwargs ): + """ + :keyword description: Description of the Tag. + :paramtype description: str + :keyword external_docs_url: Absolute URL of external resources describing the tag. + :paramtype external_docs_url: str + :keyword external_docs_description: Description of the external resources describing the tag. + :paramtype external_docs_description: str + """ super(TagDescriptionCreateParameters, self).__init__(**kwargs) self.description = description self.external_docs_url = external_docs_url @@ -12380,12 +17605,12 @@ def __init__( class TagResourceCollection(msrest.serialization.Model): """Paged Tag list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.TagResourceContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.TagResourceContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -12402,6 +17627,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.TagResourceContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(TagResourceCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -12413,14 +17646,14 @@ class TagResourceContract(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param tag: Required. Tag associated with the resource. - :type tag: ~azure.mgmt.apimanagement.models.TagResourceContractProperties - :param api: Api associated with the tag. - :type api: ~azure.mgmt.apimanagement.models.ApiTagResourceContractProperties - :param operation: Operation associated with the tag. - :type operation: ~azure.mgmt.apimanagement.models.OperationTagResourceContractProperties - :param product: Product associated with the tag. - :type product: ~azure.mgmt.apimanagement.models.ProductTagResourceContractProperties + :ivar tag: Required. Tag associated with the resource. + :vartype tag: ~azure.mgmt.apimanagement.models.TagResourceContractProperties + :ivar api: API associated with the tag. + :vartype api: ~azure.mgmt.apimanagement.models.ApiTagResourceContractProperties + :ivar operation: Operation associated with the tag. + :vartype operation: ~azure.mgmt.apimanagement.models.OperationTagResourceContractProperties + :ivar product: Product associated with the tag. + :vartype product: ~azure.mgmt.apimanagement.models.ProductTagResourceContractProperties """ _validation = { @@ -12443,6 +17676,16 @@ def __init__( product: Optional["ProductTagResourceContractProperties"] = None, **kwargs ): + """ + :keyword tag: Required. Tag associated with the resource. + :paramtype tag: ~azure.mgmt.apimanagement.models.TagResourceContractProperties + :keyword api: API associated with the tag. + :paramtype api: ~azure.mgmt.apimanagement.models.ApiTagResourceContractProperties + :keyword operation: Operation associated with the tag. + :paramtype operation: ~azure.mgmt.apimanagement.models.OperationTagResourceContractProperties + :keyword product: Product associated with the tag. + :paramtype product: ~azure.mgmt.apimanagement.models.ProductTagResourceContractProperties + """ super(TagResourceContract, self).__init__(**kwargs) self.tag = tag self.api = api @@ -12453,10 +17696,10 @@ def __init__( class TagResourceContractProperties(msrest.serialization.Model): """Contract defining the Tag property in the Tag Resource Contract. - :param id: Tag identifier. - :type id: str - :param name: Tag Name. - :type name: str + :ivar id: Tag identifier. + :vartype id: str + :ivar name: Tag Name. + :vartype name: str """ _validation = { @@ -12475,37 +17718,61 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword id: Tag identifier. + :paramtype id: str + :keyword name: Tag Name. + :paramtype name: str + """ super(TagResourceContractProperties, self).__init__(**kwargs) self.id = id self.name = name -class TenantConfigurationSyncStateContract(msrest.serialization.Model): +class TenantConfigurationSyncStateContract(Resource): """Result of Tenant Configuration Sync State. - :param branch: The name of Git branch. - :type branch: str - :param commit_id: The latest commit Id. - :type commit_id: str - :param is_export: value indicating if last sync was save (true) or deploy (false) operation. - :type is_export: bool - :param is_synced: value indicating if last synchronization was later than the configuration + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar branch: The name of Git branch. + :vartype branch: str + :ivar commit_id: The latest commit Id. + :vartype commit_id: str + :ivar is_export: value indicating if last sync was save (true) or deploy (false) operation. + :vartype is_export: bool + :ivar is_synced: value indicating if last synchronization was later than the configuration change. - :type is_synced: bool - :param is_git_enabled: value indicating whether Git configuration access is enabled. - :type is_git_enabled: bool - :param sync_date: The date of the latest synchronization. The date conforms to the following + :vartype is_synced: bool + :ivar is_git_enabled: value indicating whether Git configuration access is enabled. + :vartype is_git_enabled: bool + :ivar sync_date: The date of the latest synchronization. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type sync_date: ~datetime.datetime - :param configuration_change_date: The date of the latest configuration change. The date - conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 - standard. - :type configuration_change_date: ~datetime.datetime - :param last_operation_id: Most recent tenant configuration operation identifier. - :type last_operation_id: str + :vartype sync_date: ~datetime.datetime + :ivar configuration_change_date: The date of the latest configuration change. The date conforms + to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype configuration_change_date: ~datetime.datetime + :ivar last_operation_id: Most recent tenant configuration operation identifier. + :vartype last_operation_id: str """ + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'branch': {'key': 'properties.branch', 'type': 'str'}, 'commit_id': {'key': 'properties.commitId', 'type': 'str'}, 'is_export': {'key': 'properties.isExport', 'type': 'bool'}, @@ -12529,6 +17796,28 @@ def __init__( last_operation_id: Optional[str] = None, **kwargs ): + """ + :keyword branch: The name of Git branch. + :paramtype branch: str + :keyword commit_id: The latest commit Id. + :paramtype commit_id: str + :keyword is_export: value indicating if last sync was save (true) or deploy (false) operation. + :paramtype is_export: bool + :keyword is_synced: value indicating if last synchronization was later than the configuration + change. + :paramtype is_synced: bool + :keyword is_git_enabled: value indicating whether Git configuration access is enabled. + :paramtype is_git_enabled: bool + :keyword sync_date: The date of the latest synchronization. The date conforms to the following + format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :paramtype sync_date: ~datetime.datetime + :keyword configuration_change_date: The date of the latest configuration change. The date + conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 + standard. + :paramtype configuration_change_date: ~datetime.datetime + :keyword last_operation_id: Most recent tenant configuration operation identifier. + :paramtype last_operation_id: str + """ super(TenantConfigurationSyncStateContract, self).__init__(**kwargs) self.branch = branch self.commit_id = commit_id @@ -12565,6 +17854,8 @@ def __init__( self, **kwargs ): + """ + """ super(TenantSettingsCollection, self).__init__(**kwargs) self.value = None self.next_link = None @@ -12575,14 +17866,16 @@ class TenantSettingsContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param settings: Tenant settings. - :type settings: dict[str, str] + :ivar settings: Tenant settings. + :vartype settings: dict[str, str] """ _validation = { @@ -12604,6 +17897,10 @@ def __init__( settings: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword settings: Tenant settings. + :paramtype settings: dict[str, str] + """ super(TenantSettingsContract, self).__init__(**kwargs) self.settings = settings @@ -12611,12 +17908,12 @@ def __init__( class TermsOfServiceProperties(msrest.serialization.Model): """Terms of service contract properties. - :param text: A terms of service text. - :type text: str - :param enabled: Display terms of service during a sign-up process. - :type enabled: bool - :param consent_required: Ask user for consent to the terms of service. - :type consent_required: bool + :ivar text: A terms of service text. + :vartype text: str + :ivar enabled: Display terms of service during a sign-up process. + :vartype enabled: bool + :ivar consent_required: Ask user for consent to the terms of service. + :vartype consent_required: bool """ _attribute_map = { @@ -12633,6 +17930,14 @@ def __init__( consent_required: Optional[bool] = None, **kwargs ): + """ + :keyword text: A terms of service text. + :paramtype text: str + :keyword enabled: Display terms of service during a sign-up process. + :paramtype enabled: bool + :keyword consent_required: Ask user for consent to the terms of service. + :paramtype consent_required: bool + """ super(TermsOfServiceProperties, self).__init__(**kwargs) self.text = text self.enabled = enabled @@ -12644,10 +17949,10 @@ class TokenBodyParameterContract(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. body parameter name. - :type name: str - :param value: Required. body parameter value. - :type value: str + :ivar name: Required. body parameter name. + :vartype name: str + :ivar value: Required. body parameter value. + :vartype value: str """ _validation = { @@ -12667,6 +17972,12 @@ def __init__( value: str, **kwargs ): + """ + :keyword name: Required. body parameter name. + :paramtype name: str + :keyword value: Required. body parameter value. + :paramtype value: str + """ super(TokenBodyParameterContract, self).__init__(**kwargs) self.name = name self.value = value @@ -12675,12 +17986,12 @@ def __init__( class UserCollection(msrest.serialization.Model): """Paged Users list representation. - :param value: Page values. - :type value: list[~azure.mgmt.apimanagement.models.UserContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.UserContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -12697,6 +18008,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.UserContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(UserCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -12708,30 +18027,32 @@ class UserContract(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type for API Management resource. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param state: Account state. Specifies whether the user is active or not. Blocked users are + :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". - :type state: str or ~azure.mgmt.apimanagement.models.UserState - :param note: Optional note about a user set by the administrator. - :type note: str - :param identities: Collection of user identities. - :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :param first_name: First name. - :type first_name: str - :param last_name: Last name. - :type last_name: str - :param email: Email address. - :type email: str - :param registration_date: Date of user registration. The date conforms to the following format: + :vartype state: str or ~azure.mgmt.apimanagement.models.UserState + :ivar note: Optional note about a user set by the administrator. + :vartype note: str + :ivar identities: Collection of user identities. + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :ivar first_name: First name. + :vartype first_name: str + :ivar last_name: Last name. + :vartype last_name: str + :ivar email: Email address. + :vartype email: str + :ivar registration_date: Date of user registration. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type registration_date: ~datetime.datetime + :vartype registration_date: ~datetime.datetime :ivar groups: Collection of groups user is part of. :vartype groups: list[~azure.mgmt.apimanagement.models.GroupContractProperties] """ @@ -12769,6 +18090,26 @@ def __init__( registration_date: Optional[datetime.datetime] = 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 ~azure.mgmt.apimanagement.models.UserState + :keyword note: Optional note about a user set by the administrator. + :paramtype note: str + :keyword identities: Collection of user identities. + :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :keyword first_name: First name. + :paramtype first_name: str + :keyword last_name: Last name. + :paramtype last_name: str + :keyword email: Email address. + :paramtype email: str + :keyword registration_date: Date of user registration. The date conforms to the following + format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :paramtype registration_date: ~datetime.datetime + """ super(UserContract, self).__init__(**kwargs) self.state = state self.note = note @@ -12783,15 +18124,15 @@ def __init__( class UserEntityBaseParameters(msrest.serialization.Model): """User Entity Base Parameters set. - :param state: Account state. Specifies whether the user is active or not. Blocked users are + :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". - :type state: str or ~azure.mgmt.apimanagement.models.UserState - :param note: Optional note about a user set by the administrator. - :type note: str - :param identities: Collection of user identities. - :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :vartype state: str or ~azure.mgmt.apimanagement.models.UserState + :ivar note: Optional note about a user set by the administrator. + :vartype note: str + :ivar identities: Collection of user identities. + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] """ _attribute_map = { @@ -12808,6 +18149,17 @@ def __init__( identities: Optional[List["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 ~azure.mgmt.apimanagement.models.UserState + :keyword note: Optional note about a user set by the administrator. + :paramtype note: str + :keyword identities: Collection of user identities. + :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + """ super(UserEntityBaseParameters, self).__init__(**kwargs) self.state = state self.note = note @@ -12819,24 +18171,24 @@ class UserContractProperties(UserEntityBaseParameters): Variables are only populated by the server, and will be ignored when sending a request. - :param state: Account state. Specifies whether the user is active or not. Blocked users are + :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". - :type state: str or ~azure.mgmt.apimanagement.models.UserState - :param note: Optional note about a user set by the administrator. - :type note: str - :param identities: Collection of user identities. - :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :param first_name: First name. - :type first_name: str - :param last_name: Last name. - :type last_name: str - :param email: Email address. - :type email: str - :param registration_date: Date of user registration. The date conforms to the following format: + :vartype state: str or ~azure.mgmt.apimanagement.models.UserState + :ivar note: Optional note about a user set by the administrator. + :vartype note: str + :ivar identities: Collection of user identities. + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :ivar first_name: First name. + :vartype first_name: str + :ivar last_name: Last name. + :vartype last_name: str + :ivar email: Email address. + :vartype email: str + :ivar registration_date: Date of user registration. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type registration_date: ~datetime.datetime + :vartype registration_date: ~datetime.datetime :ivar groups: Collection of groups user is part of. :vartype groups: list[~azure.mgmt.apimanagement.models.GroupContractProperties] """ @@ -12868,6 +18220,26 @@ def __init__( registration_date: Optional[datetime.datetime] = 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 ~azure.mgmt.apimanagement.models.UserState + :keyword note: Optional note about a user set by the administrator. + :paramtype note: str + :keyword identities: Collection of user identities. + :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :keyword first_name: First name. + :paramtype first_name: str + :keyword last_name: Last name. + :paramtype last_name: str + :keyword email: Email address. + :paramtype email: str + :keyword registration_date: Date of user registration. The date conforms to the following + format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :paramtype registration_date: ~datetime.datetime + """ super(UserContractProperties, self).__init__(state=state, note=note, identities=identities, **kwargs) self.first_name = first_name self.last_name = last_name @@ -12881,30 +18253,30 @@ class UserCreateParameterProperties(UserEntityBaseParameters): All required parameters must be populated in order to send to Azure. - :param state: Account state. Specifies whether the user is active or not. Blocked users are + :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". - :type state: str or ~azure.mgmt.apimanagement.models.UserState - :param note: Optional note about a user set by the administrator. - :type note: str - :param identities: Collection of user identities. - :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :param email: Required. Email address. Must not be empty and must be unique within the service + :vartype state: str or ~azure.mgmt.apimanagement.models.UserState + :ivar note: Optional note about a user set by the administrator. + :vartype note: str + :ivar identities: Collection of user identities. + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :ivar email: Required. Email address. Must not be empty and must be unique within the service instance. - :type email: str - :param first_name: Required. First name. - :type first_name: str - :param last_name: Required. Last name. - :type last_name: str - :param password: User Password. If no value is provided, a default password is generated. - :type password: str - :param app_type: Determines the type of application which send the create user request. Default + :vartype email: str + :ivar first_name: Required. First name. + :vartype first_name: str + :ivar last_name: Required. Last name. + :vartype last_name: str + :ivar password: User Password. If no value is provided, a default password is generated. + :vartype password: str + :ivar app_type: Determines the type of application which send the create user request. Default is legacy portal. Possible values include: "portal", "developerPortal". - :type app_type: str or ~azure.mgmt.apimanagement.models.AppType - :param confirmation: Determines the type of confirmation e-mail that will be sent to the newly + :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". - :type confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation + :vartype confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation """ _validation = { @@ -12939,6 +18311,32 @@ def __init__( confirmation: Optional[Union[str, "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 ~azure.mgmt.apimanagement.models.UserState + :keyword note: Optional note about a user set by the administrator. + :paramtype note: str + :keyword identities: Collection of user identities. + :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :keyword email: Required. Email address. Must not be empty and must be unique within the + service instance. + :paramtype email: str + :keyword first_name: Required. First name. + :paramtype first_name: str + :keyword last_name: Required. Last name. + :paramtype last_name: str + :keyword password: User Password. If no value is provided, a default password is generated. + :paramtype password: str + :keyword app_type: Determines the type of application which send the create user request. + Default is legacy portal. Possible values include: "portal", "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 ~azure.mgmt.apimanagement.models.Confirmation + """ super(UserCreateParameterProperties, self).__init__(state=state, note=note, identities=identities, **kwargs) self.email = email self.first_name = first_name @@ -12951,29 +18349,29 @@ def __init__( class UserCreateParameters(msrest.serialization.Model): """User create details. - :param state: Account state. Specifies whether the user is active or not. Blocked users are + :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". - :type state: str or ~azure.mgmt.apimanagement.models.UserState - :param note: Optional note about a user set by the administrator. - :type note: str - :param identities: Collection of user identities. - :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :param email: Email address. Must not be empty and must be unique within the service instance. - :type email: str - :param first_name: First name. - :type first_name: str - :param last_name: Last name. - :type last_name: str - :param password: User Password. If no value is provided, a default password is generated. - :type password: str - :param app_type: Determines the type of application which send the create user request. Default + :vartype state: str or ~azure.mgmt.apimanagement.models.UserState + :ivar note: Optional note about a user set by the administrator. + :vartype note: str + :ivar identities: Collection of user identities. + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :ivar email: Email address. Must not be empty and must be unique within the service instance. + :vartype email: str + :ivar first_name: First name. + :vartype first_name: str + :ivar last_name: Last name. + :vartype last_name: str + :ivar password: User Password. If no value is provided, a default password is generated. + :vartype password: str + :ivar app_type: Determines the type of application which send the create user request. Default is legacy portal. Possible values include: "portal", "developerPortal". - :type app_type: str or ~azure.mgmt.apimanagement.models.AppType - :param confirmation: Determines the type of confirmation e-mail that will be sent to the newly + :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". - :type confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation + :vartype confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation """ _validation = { @@ -13008,6 +18406,32 @@ def __init__( confirmation: Optional[Union[str, "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 ~azure.mgmt.apimanagement.models.UserState + :keyword note: Optional note about a user set by the administrator. + :paramtype note: str + :keyword identities: Collection of user identities. + :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :keyword email: Email address. Must not be empty and must be unique within the service + instance. + :paramtype email: str + :keyword first_name: First name. + :paramtype first_name: str + :keyword last_name: Last name. + :paramtype last_name: str + :keyword password: User Password. If no value is provided, a default password is generated. + :paramtype password: str + :keyword app_type: Determines the type of application which send the create user request. + Default is legacy portal. Possible values include: "portal", "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 ~azure.mgmt.apimanagement.models.Confirmation + """ super(UserCreateParameters, self).__init__(**kwargs) self.state = state self.note = note @@ -13023,12 +18447,12 @@ def __init__( class UserIdentityCollection(msrest.serialization.Model): """List of Users Identity list representation. - :param value: User Identity values. - :type value: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :param count: Total record count number across all pages. - :type count: long - :param next_link: Next page link if any. - :type next_link: str + :ivar value: User Identity values. + :vartype value: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str """ _attribute_map = { @@ -13045,6 +18469,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: User Identity values. + :paramtype value: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :keyword count: Total record count number across all pages. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ super(UserIdentityCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -13054,10 +18486,10 @@ def __init__( class UserIdentityContract(msrest.serialization.Model): """User identity details. - :param provider: Identity provider name. - :type provider: str - :param id: Identifier value within provider. - :type id: str + :ivar provider: Identity provider name. + :vartype provider: str + :ivar id: Identifier value within provider. + :vartype id: str """ _attribute_map = { @@ -13072,6 +18504,12 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword provider: Identity provider name. + :paramtype provider: str + :keyword id: Identifier value within provider. + :paramtype id: str + """ super(UserIdentityContract, self).__init__(**kwargs) self.provider = provider self.id = id @@ -13080,10 +18518,10 @@ def __init__( class UserIdentityProperties(msrest.serialization.Model): """UserIdentityProperties. - :param principal_id: The principal id of user assigned identity. - :type principal_id: str - :param client_id: The client id of user assigned identity. - :type client_id: str + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str """ _attribute_map = { @@ -13098,6 +18536,12 @@ def __init__( 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) self.principal_id = principal_id self.client_id = client_id @@ -13106,13 +18550,13 @@ def __init__( class UserTokenParameters(msrest.serialization.Model): """Get User Token parameters. - :param key_type: The Key to be used to generate token for user. Possible values include: + :ivar key_type: The Key to be used to generate token for user. Possible values include: "primary", "secondary". - :type key_type: str or ~azure.mgmt.apimanagement.models.KeyType - :param expiry: The Expiry time of the Token. Maximum token expiry time is set to 30 days. The + :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. - :type expiry: ~datetime.datetime + :vartype expiry: ~datetime.datetime """ _attribute_map = { @@ -13127,6 +18571,15 @@ def __init__( 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 ~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) self.key_type = key_type self.expiry = expiry @@ -13135,8 +18588,8 @@ def __init__( class UserTokenResult(msrest.serialization.Model): """Get User Token response details. - :param value: Shared Access Authorization token for the User. - :type value: str + :ivar value: Shared Access Authorization token for the User. + :vartype value: str """ _attribute_map = { @@ -13149,6 +18602,10 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword value: Shared Access Authorization token for the User. + :paramtype value: str + """ super(UserTokenResult, self).__init__(**kwargs) self.value = value @@ -13156,23 +18613,23 @@ def __init__( class UserUpdateParameters(msrest.serialization.Model): """User update parameters. - :param state: Account state. Specifies whether the user is active or not. Blocked users are + :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". - :type state: str or ~azure.mgmt.apimanagement.models.UserState - :param note: Optional note about a user set by the administrator. - :type note: str - :param identities: Collection of user identities. - :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :param email: Email address. Must not be empty and must be unique within the service instance. - :type email: str - :param password: User Password. - :type password: str - :param first_name: First name. - :type first_name: str - :param last_name: Last name. - :type last_name: str + :vartype state: str or ~azure.mgmt.apimanagement.models.UserState + :ivar note: Optional note about a user set by the administrator. + :vartype note: str + :ivar identities: Collection of user identities. + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :ivar email: Email address. Must not be empty and must be unique within the service instance. + :vartype email: str + :ivar password: User Password. + :vartype password: str + :ivar first_name: First name. + :vartype first_name: str + :ivar last_name: Last name. + :vartype last_name: str """ _validation = { @@ -13203,6 +18660,26 @@ def __init__( last_name: Optional[str] = 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 ~azure.mgmt.apimanagement.models.UserState + :keyword note: Optional note about a user set by the administrator. + :paramtype note: str + :keyword identities: Collection of user identities. + :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :keyword email: Email address. Must not be empty and must be unique within the service + instance. + :paramtype email: str + :keyword password: User Password. + :paramtype password: str + :keyword first_name: First name. + :paramtype first_name: str + :keyword last_name: Last name. + :paramtype last_name: str + """ super(UserUpdateParameters, self).__init__(**kwargs) self.state = state self.note = note @@ -13216,23 +18693,23 @@ def __init__( class UserUpdateParametersProperties(UserEntityBaseParameters): """Parameters supplied to the Update User operation. - :param state: Account state. Specifies whether the user is active or not. Blocked users are + :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". - :type state: str or ~azure.mgmt.apimanagement.models.UserState - :param note: Optional note about a user set by the administrator. - :type note: str - :param identities: Collection of user identities. - :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :param email: Email address. Must not be empty and must be unique within the service instance. - :type email: str - :param password: User Password. - :type password: str - :param first_name: First name. - :type first_name: str - :param last_name: Last name. - :type last_name: str + :vartype state: str or ~azure.mgmt.apimanagement.models.UserState + :ivar note: Optional note about a user set by the administrator. + :vartype note: str + :ivar identities: Collection of user identities. + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :ivar email: Email address. Must not be empty and must be unique within the service instance. + :vartype email: str + :ivar password: User Password. + :vartype password: str + :ivar first_name: First name. + :vartype first_name: str + :ivar last_name: Last name. + :vartype last_name: str """ _validation = { @@ -13263,6 +18740,26 @@ def __init__( last_name: Optional[str] = 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 ~azure.mgmt.apimanagement.models.UserState + :keyword note: Optional note about a user set by the administrator. + :paramtype note: str + :keyword identities: Collection of user identities. + :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :keyword email: Email address. Must not be empty and must be unique within the service + instance. + :paramtype email: str + :keyword password: User Password. + :paramtype password: str + :keyword first_name: First name. + :paramtype first_name: str + :keyword last_name: Last name. + :paramtype last_name: str + """ super(UserUpdateParametersProperties, self).__init__(state=state, note=note, identities=identities, **kwargs) self.email = email self.password = password @@ -13279,9 +18776,9 @@ class VirtualNetworkConfiguration(msrest.serialization.Model): :vartype vnetid: str :ivar subnetname: The name of the subnet. :vartype subnetname: str - :param subnet_resource_id: The full resource ID of a subnet in a virtual network to deploy the + :ivar subnet_resource_id: The full resource ID of a subnet in a virtual network to deploy the API Management service in. - :type subnet_resource_id: str + :vartype subnet_resource_id: str """ _validation = { @@ -13302,6 +18799,11 @@ def __init__( 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) self.vnetid = None self.subnetname = None @@ -13311,10 +18813,10 @@ def __init__( class X509CertificateName(msrest.serialization.Model): """Properties of server X509Names. - :param name: Common Name of the Certificate. - :type name: str - :param issuer_certificate_thumbprint: Thumbprint for the Issuer of the Certificate. - :type issuer_certificate_thumbprint: str + :ivar name: Common Name of the Certificate. + :vartype name: str + :ivar issuer_certificate_thumbprint: Thumbprint for the Issuer of the Certificate. + :vartype issuer_certificate_thumbprint: str """ _attribute_map = { @@ -13329,6 +18831,12 @@ def __init__( 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) self.name = name self.issuer_certificate_thumbprint = issuer_certificate_thumbprint 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 cd77fa38b0bab..9f8b6482fabbe 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 @@ -27,6 +27,7 @@ from ._backend_operations import BackendOperations from ._cache_operations import CacheOperations from ._certificate_operations import CertificateOperations +from ._api_management_client_operations import ApiManagementClientOperationsMixin from ._content_type_operations import ContentTypeOperations from ._content_item_operations import ContentItemOperations from ._deleted_services_operations import DeletedServicesOperations @@ -50,6 +51,7 @@ from ._notification_recipient_user_operations import NotificationRecipientUserOperations from ._notification_recipient_email_operations import NotificationRecipientEmailOperations from ._open_id_connect_provider_operations import OpenIdConnectProviderOperations +from ._outbound_network_dependencies_endpoints_operations import OutboundNetworkDependenciesEndpointsOperations from ._policy_operations import PolicyOperations from ._policy_description_operations import PolicyDescriptionOperations from ._portal_revision_operations import PortalRevisionOperations @@ -57,6 +59,7 @@ from ._sign_in_settings_operations import SignInSettingsOperations from ._sign_up_settings_operations import SignUpSettingsOperations from ._delegation_settings_operations import DelegationSettingsOperations +from ._private_endpoint_connection_operations import PrivateEndpointConnectionOperations from ._product_operations import ProductOperations from ._product_api_operations import ProductApiOperations from ._product_group_operations import ProductGroupOperations @@ -66,6 +69,7 @@ from ._quota_by_period_keys_operations import QuotaByPeriodKeysOperations from ._region_operations import RegionOperations from ._reports_operations import ReportsOperations +from ._global_schema_operations import GlobalSchemaOperations from ._tenant_settings_operations import TenantSettingsOperations from ._api_management_skus_operations import ApiManagementSkusOperations from ._subscription_operations import SubscriptionOperations @@ -101,6 +105,7 @@ 'BackendOperations', 'CacheOperations', 'CertificateOperations', + 'ApiManagementClientOperationsMixin', 'ContentTypeOperations', 'ContentItemOperations', 'DeletedServicesOperations', @@ -124,6 +129,7 @@ 'NotificationRecipientUserOperations', 'NotificationRecipientEmailOperations', 'OpenIdConnectProviderOperations', + 'OutboundNetworkDependenciesEndpointsOperations', 'PolicyOperations', 'PolicyDescriptionOperations', 'PortalRevisionOperations', @@ -131,6 +137,7 @@ 'SignInSettingsOperations', 'SignUpSettingsOperations', 'DelegationSettingsOperations', + 'PrivateEndpointConnectionOperations', 'ProductOperations', 'ProductApiOperations', 'ProductGroupOperations', @@ -140,6 +147,7 @@ 'QuotaByPeriodKeysOperations', 'RegionOperations', 'ReportsOperations', + 'GlobalSchemaOperations', 'TenantSettingsOperations', 'ApiManagementSkusOperations', 'SubscriptionOperations', 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 5591441b5ee69..8b1029155d12a 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 @@ -5,23 +5,294 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + api_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + api_id: str, + diagnostic_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + api_id: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,17 +316,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DiagnosticCollection"] + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.DiagnosticCollection"]: """Lists all diagnostics of an API. :param resource_group_name: The name of the resource group. @@ -73,7 +344,8 @@ def list_by_service( :param skip: Number of records to skip. :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 DiagnosticCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.DiagnosticCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -82,43 +354,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DiagnosticCollection', pipeline_response) + deserialized = self._deserialize("DiagnosticCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -131,26 +401,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - api_id, # type: str - diagnostic_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -172,55 +443,47 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace def get( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - diagnostic_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DiagnosticContract" + 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. @@ -242,58 +505,51 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - diagnostic_id, # type: str - parameters, # type: "_models.DiagnosticContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.DiagnosticContract" + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + parameters: "_models.DiagnosticContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.DiagnosticContract": """Creates a new Diagnostic for an API or updates an existing one. :param resource_group_name: The name of the resource group. @@ -320,70 +576,63 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DiagnosticContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DiagnosticContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - diagnostic_id, # type: str - if_match, # type: str - parameters, # type: "_models.DiagnosticContract" - **kwargs # type: Any - ): - # type: (...) -> "_models.DiagnosticContract" + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + if_match: str, + parameters: "_models.DiagnosticContract", + **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. @@ -410,63 +659,56 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DiagnosticContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DiagnosticContract') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - diagnostic_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -491,39 +733,30 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 44f07f174452f..2234c1bd4e08b 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 @@ -5,22 +5,66 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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"], + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # 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') + + # 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. @@ -44,16 +88,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - format, # type: Union[str, "_models.ExportFormat"] - export, # type: Union[str, "_models.ExportApi"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ApiExportResult" + resource_group_name: str, + service_name: str, + api_id: str, + format: Union[str, "_models.ExportFormat"], + export: Union[str, "_models.ExportApi"], + **kwargs: Any + ) -> "_models.ApiExportResult": """Gets the details of the API specified by its identifier in the format specified to the Storage Blob with SAS Key valid for 5 minutes. @@ -79,36 +123,26 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['format'] = self._serialize.query("format", format, 'str') - query_parameters['export'] = self._serialize.query("export", export, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + format=format, + export=export, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApiExportResult', pipeline_response) @@ -117,4 +151,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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 f58a3040ef065..147b81c005f61 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 @@ -5,23 +5,254 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + api_id: str, + issue_id: str, + attachment_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,18 +276,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - issue_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IssueAttachmentCollection"] + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.IssueAttachmentCollection"]: """Lists all attachments for the Issue associated with the specified API. :param resource_group_name: The name of the resource group. @@ -78,8 +309,10 @@ def list_by_service( :param skip: Number of records to skip. :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 cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IssueAttachmentCollection] + :return: An iterator like instance of either IssueAttachmentCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IssueAttachmentCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueAttachmentCollection"] @@ -87,44 +320,43 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IssueAttachmentCollection', pipeline_response) + deserialized = self._deserialize("IssueAttachmentCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -137,27 +369,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - api_id, # type: str - issue_id, # type: str - attachment_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -183,57 +416,49 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + attachment_id=attachment_id, + subscription_id=self._config.subscription_id, + template_url=self.get_entity_tag.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace def get( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - issue_id, # type: str - attachment_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.IssueAttachmentContract" + 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. @@ -258,60 +483,53 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + attachment_id=attachment_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueAttachmentContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - issue_id, # type: str - attachment_id, # type: str - parameters, # type: "_models.IssueAttachmentContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.IssueAttachmentContract" + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + parameters: "_models.IssueAttachmentContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.IssueAttachmentContract": """Creates a new Attachment for the Issue in an API or updates an existing one. :param resource_group_name: The name of the resource group. @@ -341,71 +559,64 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'IssueAttachmentContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'IssueAttachmentContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + attachment_id=attachment_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - issue_id, # type: str - attachment_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + if_match: str, + **kwargs: Any + ) -> None: """Deletes the specified comment from an Issue. :param resource_group_name: The name of the resource group. @@ -433,40 +644,31 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + attachment_id=attachment_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 c6304d2026a83..f635cd901533c 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 @@ -5,23 +5,254 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + api_id: str, + issue_id: str, + comment_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,18 +276,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - issue_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IssueCommentCollection"] + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.IssueCommentCollection"]: """Lists all comments for the Issue associated with the specified API. :param resource_group_name: The name of the resource group. @@ -78,7 +309,8 @@ def list_by_service( :param skip: Number of records to skip. :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 cls(response) + :return: An iterator like instance of either IssueCommentCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IssueCommentCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -87,44 +319,43 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IssueCommentCollection', pipeline_response) + deserialized = self._deserialize("IssueCommentCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -137,27 +368,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - api_id, # type: str - issue_id, # type: str - comment_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -182,57 +414,49 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'commentId': self._serialize.url("comment_id", comment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + comment_id=comment_id, + subscription_id=self._config.subscription_id, + template_url=self.get_entity_tag.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace def get( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - issue_id, # type: str - comment_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.IssueCommentContract" + 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. @@ -256,60 +480,53 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'commentId': self._serialize.url("comment_id", comment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + comment_id=comment_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueCommentContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - issue_id, # type: str - comment_id, # type: str - parameters, # type: "_models.IssueCommentContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.IssueCommentContract" + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + parameters: "_models.IssueCommentContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.IssueCommentContract": """Creates a new Comment for the Issue in an API or updates an existing one. :param resource_group_name: The name of the resource group. @@ -338,71 +555,64 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'commentId': self._serialize.url("comment_id", comment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'IssueCommentContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'IssueCommentContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + comment_id=comment_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - issue_id, # type: str - comment_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + if_match: str, + **kwargs: Any + ) -> None: """Deletes the specified comment from an Issue. :param resource_group_name: The name of the resource group. @@ -429,40 +639,31 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'commentId': self._serialize.url("comment_id", comment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + comment_id=comment_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 1f84a4a17361b..a97804ca36254 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 @@ -5,23 +5,301 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + api_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + expand_comments_attachments: Optional[bool] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$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') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + api_id: str, + issue_id: str, + subscription_id: str, + *, + expand_comments_attachments: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # 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') + + # 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_create_or_update_request( + resource_group_name: str, + service_name: str, + api_id: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + api_id: str, + issue_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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,18 +323,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - filter=None, # type: Optional[str] - expand_comments_attachments=None, # type: Optional[bool] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IssueCollection"] + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + expand_comments_attachments: Optional[bool] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.IssueCollection"]: """Lists all issues associated with the specified API. :param resource_group_name: The name of the resource group. @@ -87,45 +365,43 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand_comments_attachments is not None: - query_parameters['expandCommentsAttachments'] = self._serialize.query("expand_comments_attachments", expand_comments_attachments, 'bool') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IssueCollection', pipeline_response) + deserialized = self._deserialize("IssueCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -138,26 +414,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - api_id, # type: str - issue_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -179,56 +456,48 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace def get( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - issue_id, # type: str - expand_comments_attachments=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> "_models.IssueContract" + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + expand_comments_attachments: Optional[bool] = None, + **kwargs: Any + ) -> "_models.IssueContract": """Gets the details of the Issue for an API specified by its identifier. :param resource_group_name: The name of the resource group. @@ -252,60 +521,52 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand_comments_attachments is not None: - query_parameters['expandCommentsAttachments'] = self._serialize.query("expand_comments_attachments", expand_comments_attachments, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + expand_comments_attachments=expand_comments_attachments, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - issue_id, # type: str - parameters, # type: "_models.IssueContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.IssueContract" + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + parameters: "_models.IssueContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.IssueContract": """Creates a new Issue for an API or updates an existing one. :param resource_group_name: The name of the resource group. @@ -332,70 +593,63 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'IssueContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'IssueContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - issue_id, # type: str - if_match, # type: str - parameters, # type: "_models.IssueUpdateContract" - **kwargs # type: Any - ): - # type: (...) -> "_models.IssueContract" + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + if_match: str, + parameters: "_models.IssueUpdateContract", + **kwargs: Any + ) -> "_models.IssueContract": """Updates an existing issue for an API. :param resource_group_name: The name of the resource group. @@ -422,63 +676,56 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'IssueUpdateContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'IssueUpdateContract') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - issue_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -503,39 +750,30 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 new file mode 100644 index 0000000000000..8b6bef22c7375 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_client_operations.py @@ -0,0 +1,195 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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 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.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 +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 +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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 ApiManagementClientOperationsMixin(object): + + def _perform_connectivity_check_async_initial( + self, + resource_group_name: str, + service_name: str, + connectivity_check_request_params: "_models.ConnectivityCheckRequest", + **kwargs: Any + ) -> Optional["_models.ConnectivityCheckResponse"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ConnectivityCheckResponse"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(connectivity_check_request_params, 'ConnectivityCheckRequest') + + request = build_perform_connectivity_check_async_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._perform_connectivity_check_async_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + + deserialized = None + if response.status_code == 200: + 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 + + + @distributed_trace + def begin_perform_connectivity_check_async( + self, + resource_group_name: str, + service_name: str, + connectivity_check_request_params: "_models.ConnectivityCheckRequest", + **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. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param connectivity_check_request_params: Connectivity Check request parameters. + :type connectivity_check_request_params: + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequest + :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 + """ + 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] + if cont_token is None: + raw_result = self._perform_connectivity_check_async_initial( + resource_group_name=resource_group_name, + service_name=service_name, + connectivity_check_request_params=connectivity_check_request_params, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_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 cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + 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 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 5d4b1eca99670..00922f9f87d25 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 @@ -5,23 +5,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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" + # Construct URL + 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') + + # 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. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """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 @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +122,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_operations.py index c2022facb7e4c..d8bbe47565fc2 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 @@ -5,25 +5,488 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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 +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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 +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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 +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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 +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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 +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service') + path_format_arguments = { + "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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_get_sso_token_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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] + + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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 +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -49,50 +512,38 @@ def __init__(self, client, config, serializer, deserializer): def _restore_initial( self, - resource_group_name, # type: str - service_name, # type: str - parameters, # type: "_models.ApiManagementServiceBackupRestoreParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ApiManagementServiceResource"] + resource_group_name: str, + service_name: str, + parameters: "_models.ApiManagementServiceBackupRestoreParameters", + **kwargs: Any + ) -> Optional["_models.ApiManagementServiceResource"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._restore_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') + + request = build_restore_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._restore_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -102,16 +553,18 @@ def _restore_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _restore_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore'} # type: ignore + + @distributed_trace def begin_restore( self, - resource_group_name, # type: str - service_name, # type: str - parameters, # type: "_models.ApiManagementServiceBackupRestoreParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ApiManagementServiceResource"] + resource_group_name: str, + service_name: str, + parameters: "_models.ApiManagementServiceBackupRestoreParameters", + **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. @@ -125,15 +578,20 @@ def begin_restore( :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters :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. + :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: + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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', @@ -145,27 +603,21 @@ def begin_restore( resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -177,54 +629,43 @@ def get_long_running_output(pipeline_response): ) else: 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 def _backup_initial( self, - resource_group_name, # type: str - service_name, # type: str - parameters, # type: "_models.ApiManagementServiceBackupRestoreParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ApiManagementServiceResource"] + resource_group_name: str, + service_name: str, + parameters: "_models.ApiManagementServiceBackupRestoreParameters", + **kwargs: Any + ) -> Optional["_models.ApiManagementServiceResource"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._backup_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') + + request = build_backup_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._backup_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -234,16 +675,18 @@ def _backup_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _backup_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup'} # type: ignore + + @distributed_trace def begin_backup( self, - resource_group_name, # type: str - service_name, # type: str - parameters, # type: "_models.ApiManagementServiceBackupRestoreParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ApiManagementServiceResource"] + resource_group_name: str, + service_name: str, + parameters: "_models.ApiManagementServiceBackupRestoreParameters", + **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. @@ -255,15 +698,20 @@ def begin_backup( :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters :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. + :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: + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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', @@ -275,27 +723,21 @@ def begin_backup( resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -307,54 +749,43 @@ def get_long_running_output(pipeline_response): ) else: 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 def _create_or_update_initial( self, - resource_group_name, # type: str - service_name, # type: str - parameters, # type: "_models.ApiManagementServiceResource" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ApiManagementServiceResource"] + resource_group_name: str, + service_name: str, + parameters: "_models.ApiManagementServiceResource", + **kwargs: Any + ) -> Optional["_models.ApiManagementServiceResource"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ApiManagementServiceResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiManagementServiceResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -367,16 +798,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - parameters, # type: "_models.ApiManagementServiceResource" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ApiManagementServiceResource"] + resource_group_name: str, + service_name: str, + parameters: "_models.ApiManagementServiceResource", + **kwargs: Any + ) -> LROPoller["_models.ApiManagementServiceResource"]: """Creates or updates an API Management service. This is long running operation and could take several minutes to complete. @@ -388,15 +821,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource :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. + :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: + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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', @@ -408,27 +846,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -440,54 +872,43 @@ def get_long_running_output(pipeline_response): ) else: 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 def _update_initial( self, - resource_group_name, # type: str - service_name, # type: str - parameters, # type: "_models.ApiManagementServiceUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ApiManagementServiceResource"] + resource_group_name: str, + service_name: str, + parameters: "_models.ApiManagementServiceUpdateParameters", + **kwargs: Any + ) -> Optional["_models.ApiManagementServiceResource"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ApiManagementServiceUpdateParameters') + + request = build_update_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiManagementServiceUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -497,16 +918,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - service_name, # type: str - parameters, # type: "_models.ApiManagementServiceUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ApiManagementServiceResource"] + resource_group_name: str, + service_name: str, + parameters: "_models.ApiManagementServiceUpdateParameters", + **kwargs: Any + ) -> LROPoller["_models.ApiManagementServiceResource"]: """Updates an existing API Management service. :param resource_group_name: The name of the resource group. @@ -517,15 +940,20 @@ def begin_update( :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceUpdateParameters :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. + :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: + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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', @@ -537,27 +965,21 @@ def begin_update( resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -569,15 +991,16 @@ def get_long_running_output(pipeline_response): ) else: 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 + @distributed_trace def get( self, - resource_group_name, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApiManagementServiceResource" + 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. @@ -594,33 +1017,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) @@ -629,48 +1042,38 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + def _delete_initial( self, - resource_group_name, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ApiManagementServiceResource"] + resource_group_name: str, + service_name: str, + **kwargs: Any + ) -> Optional["_models.ApiManagementServiceResource"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 202: @@ -680,15 +1083,17 @@ def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ApiManagementServiceResource"] + resource_group_name: str, + service_name: str, + **kwargs: Any + ) -> LROPoller["_models.ApiManagementServiceResource"]: """Deletes an existing API Management service. :param resource_group_name: The name of the resource group. @@ -697,15 +1102,19 @@ def begin_delete( :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. - :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. + :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 None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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', @@ -719,24 +1128,17 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -748,21 +1150,24 @@ def get_long_running_output(pipeline_response): ) else: 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 + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApiManagementServiceListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ApiManagementServiceListResult"]: """List all API Management services within a resource group. :param resource_group_name: The name of the resource group. :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 cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceListResult] + :return: An iterator like instance of either ApiManagementServiceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceListResult"] @@ -770,35 +1175,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApiManagementServiceListResult', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -811,27 +1212,30 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service'} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApiManagementServiceListResult"] + **kwargs: Any + ) -> Iterable["_models.ApiManagementServiceListResult"]: """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 cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceListResult] + :return: An iterator like instance of either ApiManagementServiceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceListResult"] @@ -839,34 +1243,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApiManagementServiceListResult', pipeline_response) + deserialized = self._deserialize("ApiManagementServiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -879,24 +1278,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service'} # type: ignore + @distributed_trace def get_sso_token( self, - resource_group_name, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApiManagementServiceGetSsoTokenResult" + 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. @@ -913,33 +1313,23 @@ def get_sso_token( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_sso_token.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApiManagementServiceGetSsoTokenResult', pipeline_response) @@ -948,18 +1338,21 @@ def get_sso_token( return cls(pipeline_response, deserialized, {}) return deserialized + get_sso_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken'} # type: ignore + + @distributed_trace def check_name_availability( self, - parameters, # type: "_models.ApiManagementServiceCheckNameAvailabilityParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApiManagementServiceNameAvailabilityResult" + parameters: "_models.ApiManagementServiceCheckNameAvailabilityParameters", + **kwargs: Any + ) -> "_models.ApiManagementServiceNameAvailabilityResult": """Checks availability and correctness of a name for an API Management service. :param parameters: Parameters supplied to the CheckNameAvailability operation. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceCheckNameAvailabilityParameters + :type parameters: + ~azure.mgmt.apimanagement.models.ApiManagementServiceCheckNameAvailabilityParameters :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 @@ -970,36 +1363,26 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'ApiManagementServiceCheckNameAvailabilityParameters') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiManagementServiceCheckNameAvailabilityParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApiManagementServiceNameAvailabilityResult', pipeline_response) @@ -1008,13 +1391,15 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability'} # type: ignore + + @distributed_trace def get_domain_ownership_identifier( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.ApiManagementServiceGetDomainOwnershipIdentifierResult" + **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 @@ -1027,31 +1412,21 @@ def get_domain_ownership_identifier( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - # Construct URL - url = self.get_domain_ownership_identifier.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_domain_ownership_identifier_request( + subscription_id=self._config.subscription_id, + template_url=self.get_domain_ownership_identifier.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApiManagementServiceGetDomainOwnershipIdentifierResult', pipeline_response) @@ -1060,57 +1435,47 @@ def get_domain_ownership_identifier( return cls(pipeline_response, deserialized, {}) return deserialized + get_domain_ownership_identifier.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier'} # type: ignore + def _apply_network_configuration_updates_initial( self, - resource_group_name, # type: str - service_name, # type: str - parameters=None, # type: Optional["_models.ApiManagementServiceApplyNetworkConfigurationParameters"] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ApiManagementServiceResource"] + resource_group_name: str, + service_name: str, + parameters: Optional["_models.ApiManagementServiceApplyNetworkConfigurationParameters"] = None, + **kwargs: Any + ) -> Optional["_models.ApiManagementServiceResource"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._apply_network_configuration_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'ApiManagementServiceApplyNetworkConfigurationParameters') + _json = self._serialize.body(parameters, 'ApiManagementServiceApplyNetworkConfigurationParameters') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_apply_network_configuration_updates_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._apply_network_configuration_updates_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -1120,16 +1485,18 @@ def _apply_network_configuration_updates_initial( 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 + + @distributed_trace def begin_apply_network_configuration_updates( self, - resource_group_name, # type: str - service_name, # type: str - parameters=None, # type: Optional["_models.ApiManagementServiceApplyNetworkConfigurationParameters"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ApiManagementServiceResource"] + resource_group_name: str, + service_name: str, + parameters: Optional["_models.ApiManagementServiceApplyNetworkConfigurationParameters"] = None, + **kwargs: Any + ) -> LROPoller["_models.ApiManagementServiceResource"]: """Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated DNS changes. @@ -1140,18 +1507,24 @@ def begin_apply_network_configuration_updates( :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. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceApplyNetworkConfigurationParameters + :type parameters: + ~azure.mgmt.apimanagement.models.ApiManagementServiceApplyNetworkConfigurationParameters :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. + :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: + :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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', @@ -1163,27 +1536,21 @@ def begin_apply_network_configuration_updates( resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -1195,4 +1562,5 @@ def get_long_running_output(pipeline_response): ) else: 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 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 e10caea097547..1e88165572655 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 @@ -5,23 +5,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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 +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,13 +82,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_available_service_skus( self, - resource_group_name, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ResourceSkuResults"] + resource_group_name: str, + service_name: str, + **kwargs: Any + ) -> Iterable["_models.ResourceSkuResults"]: """Gets available SKUs for API Management service. Gets all available SKU for a given API Management service. @@ -70,36 +107,33 @@ def list_available_service_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_available_service_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ResourceSkuResults', pipeline_response) + deserialized = self._deserialize("ResourceSkuResults", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,12 +146,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_skus_operations.py index 0e9f55e36f75d..e551950dbf94e 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 @@ -5,23 +5,56 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/skus') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,15 +78,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApiManagementSkusResult"] + **kwargs: Any + ) -> Iterable["_models.ApiManagementSkusResult"]: """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 ApiManagementSkusResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -62,34 +96,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApiManagementSkusResult', pipeline_response) + deserialized = self._deserialize("ApiManagementSkusResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,12 +131,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_operations.py index a462d56086b1e..cdc1116425aa8 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 @@ -5,23 +5,297 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_api_request( + resource_group_name: str, + service_name: str, + api_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + tags: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + api_id: str, + operation_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + api_id: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + api_id: str, + operation_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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,18 +319,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_api( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - tags=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationCollection"] + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + tags: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.OperationCollection"]: """Lists a collection of the operations for the specified API. :param resource_group_name: The name of the resource group. @@ -91,45 +365,43 @@ def list_by_api( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_api.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_api.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationCollection', pipeline_response) + deserialized = self._deserialize("OperationCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -142,26 +414,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - api_id, # type: str - operation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -184,55 +457,47 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace def get( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - operation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.OperationContract" + 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. @@ -255,58 +520,51 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OperationContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - operation_id, # type: str - parameters, # type: "_models.OperationContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.OperationContract" + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + parameters: "_models.OperationContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.OperationContract": """Creates a new operation in the API or updates an existing one. :param resource_group_name: The name of the resource group. @@ -334,70 +592,63 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'OperationContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'OperationContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - operation_id, # type: str - if_match, # type: str - parameters, # type: "_models.OperationUpdateContract" - **kwargs # type: Any - ): - # type: (...) -> "_models.OperationContract" + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + if_match: str, + parameters: "_models.OperationUpdateContract", + **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. @@ -425,63 +676,56 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'OperationUpdateContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'OperationUpdateContract') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OperationContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - operation_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -507,39 +751,30 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 9fd3728233548..f957c1dcc8c2b 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 @@ -5,22 +5,247 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_operation_request( + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + api_id: str, + operation_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + subscription_id: str, + *, + format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # 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') + + # 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_create_or_update_request( + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -44,15 +269,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_operation( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - operation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PolicyCollection" + 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. @@ -75,35 +300,25 @@ def list_by_operation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_operation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyCollection', pipeline_response) @@ -112,18 +327,20 @@ def list_by_operation( 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 + + @distributed_trace def get_entity_tag( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - operation_id, # type: str - policy_id, # type: Union[str, "_models.PolicyIdName"] - **kwargs # type: Any - ): - # type: (...) -> bool + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + **kwargs: Any + ) -> bool: """Gets the entity state (Etag) version of the API operation policy specified by its identifier. :param resource_group_name: The name of the resource group. @@ -148,58 +365,50 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + template_url=self.get_entity_tag.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace def get( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - operation_id, # type: str - policy_id, # type: Union[str, "_models.PolicyIdName"] - format="xml", # type: Optional[Union[str, "_models.PolicyExportFormat"]] - **kwargs # type: Any - ): - # type: (...) -> "_models.PolicyContract" + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", + **kwargs: Any + ) -> "_models.PolicyContract": """Get the policy configuration at the API Operation level. :param resource_group_name: The name of the resource group. @@ -226,62 +435,54 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if format is not None: - query_parameters['format'] = self._serialize.query("format", format, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - operation_id, # type: str - policy_id, # type: Union[str, "_models.PolicyIdName"] - parameters, # type: "_models.PolicyContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.PolicyContract" + 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, + **kwargs: Any + ) -> "_models.PolicyContract": """Creates or updates policy configuration for the API Operation level. :param resource_group_name: The name of the resource group. @@ -311,71 +512,64 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - operation_id, # type: str - policy_id, # type: Union[str, "_models.PolicyIdName"] - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + if_match: str, + **kwargs: Any + ) -> None: """Deletes the policy configuration at the Api Operation. :param resource_group_name: The name of the resource group. @@ -403,40 +597,31 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 570a6ea9accf0..ac55ae3bf4986 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 @@ -5,25 +5,341 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + tags: Optional[str] = None, + expand_api_version_set: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + if tags is not None: + query_parameters['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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + api_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + api_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request_initial( + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + api_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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + subscription_id: str, + *, + if_match: str, + delete_revisions: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # 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') + + # 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 + ) + + +def build_list_by_tags_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + include_not_tagged_apis: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apisByTags') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$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') + + # 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. @@ -47,18 +363,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - tags=None, # type: Optional[str] - expand_api_version_set=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApiCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + tags: Optional[str] = None, + expand_api_version_set: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.ApiCollection"]: """Lists all APIs of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -92,46 +408,43 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, 'str') - if expand_api_version_set is not None: - query_parameters['expandApiVersionSet'] = self._serialize.query("expand_api_version_set", expand_api_version_set, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApiCollection', pipeline_response) + deserialized = self._deserialize("ApiCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -144,25 +457,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - api_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -182,53 +496,45 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - api_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApiContract" + 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. @@ -248,129 +554,108 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json, application/vnd.swagger.doc+json, application/vnd.oai.openapi+json, application/vnd.sun.wadl+xml, application/wsdl+xml" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 200]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - deserialized = self._deserialize('ApiContract', pipeline_response) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - if response.status_code == 200: - 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 + def _create_or_update_initial( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - parameters, # type: "_models.ApiCreateOrUpdateParameter" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ApiContract"] + resource_group_name: str, + service_name: str, + api_id: str, + parameters: "_models.ApiCreateOrUpdateParameter", + if_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.ApiContract"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiContract"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiCreateOrUpdateParameter') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ApiCreateOrUpdateParameter') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiContract', pipeline_response) if response.status_code == 201: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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 + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - parameters, # type: "_models.ApiCreateOrUpdateParameter" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ApiContract"] + resource_group_name: str, + service_name: str, + api_id: str, + parameters: "_models.ApiCreateOrUpdateParameter", + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller["_models.ApiContract"]: """Creates new or updates existing specified API of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -387,15 +672,19 @@ def begin_create_or_update( :type if_match: 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. + :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) + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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', @@ -409,31 +698,24 @@ def begin_create_or_update( api_id=api_id, parameters=parameters, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', 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) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -445,18 +727,19 @@ def get_long_running_output(pipeline_response): ) else: 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 + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - if_match, # type: str - parameters, # type: "_models.ApiUpdateContract" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApiContract" + resource_group_name: str, + service_name: str, + api_id: str, + if_match: str, + parameters: "_models.ApiUpdateContract", + **kwargs: Any + ) -> "_models.ApiContract": """Updates the specified API of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -481,62 +764,55 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiUpdateContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - if_match, # type: str - delete_revisions=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + api_id: str, + if_match: str, + delete_revisions: Optional[bool] = None, + **kwargs: Any + ) -> None: """Deletes the specified API of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -561,37 +837,26 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if delete_revisions is not None: - query_parameters['deleteRevisions'] = self._serialize.query("delete_revisions", delete_revisions, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + delete_revisions=delete_revisions, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -599,17 +864,18 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + + @distributed_trace def list_by_tags( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - include_not_tagged_apis=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TagResourceCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + include_not_tagged_apis: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.TagResourceCollection"]: """Lists a collection of apis associated with tags. :param resource_group_name: The name of the resource group. @@ -633,7 +899,8 @@ def list_by_tags( :param include_not_tagged_apis: Include not tagged APIs. :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 TagResourceCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -642,44 +909,41 @@ def list_by_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if include_not_tagged_apis is not None: - query_parameters['includeNotTaggedApis'] = self._serialize.query("include_not_tagged_apis", include_not_tagged_apis, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagResourceCollection', pipeline_response) + deserialized = self._deserialize("TagResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -692,12 +956,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_policy_operations.py index 2075471cf6147..4507884408435 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 @@ -5,22 +5,237 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_api_request( + resource_group_name: str, + service_name: str, + api_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + api_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + subscription_id: str, + *, + format: Optional[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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # 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') + + # 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_create_or_update_request( + resource_group_name: str, + service_name: str, + api_id: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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 ApiPolicyOperations(object): """ApiPolicyOperations operations. @@ -44,14 +259,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_api( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PolicyCollection" + 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. @@ -71,34 +286,24 @@ def list_by_api( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_api.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyCollection', pipeline_response) @@ -107,17 +312,19 @@ def list_by_api( 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 + + @distributed_trace def get_entity_tag( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - policy_id, # type: Union[str, "_models.PolicyIdName"] - **kwargs # type: Any - ): - # type: (...) -> bool + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + **kwargs: Any + ) -> bool: """Gets the entity state (Etag) version of the API policy specified by its identifier. :param resource_group_name: The name of the resource group. @@ -139,56 +346,48 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace def get( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - policy_id, # type: Union[str, "_models.PolicyIdName"] - format="xml", # type: Optional[Union[str, "_models.PolicyExportFormat"]] - **kwargs # type: Any - ): - # type: (...) -> "_models.PolicyContract" + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", + **kwargs: Any + ) -> "_models.PolicyContract": """Get the policy configuration at the API level. :param resource_group_name: The name of the resource group. @@ -212,65 +411,58 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json, application/vnd.ms-azure-apim.policy+xml, application/vnd.ms-azure-apim.policy.raw+xml" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if format is not None: - query_parameters['format'] = self._serialize.query("format", format, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - policy_id, # type: Union[str, "_models.PolicyIdName"] - parameters, # type: "_models.PolicyContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.PolicyContract" + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + parameters: "_models.PolicyContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.PolicyContract": """Creates or updates policy configuration for the API. :param resource_group_name: The name of the resource group. @@ -297,69 +489,62 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - policy_id, # type: Union[str, "_models.PolicyIdName"] - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + if_match: str, + **kwargs: Any + ) -> None: """Deletes the policy configuration at the Api. :param resource_group_name: The name of the resource group. @@ -384,39 +569,30 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 4d225d92164ec..d307dccfe2046 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 @@ -5,23 +5,72 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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, + api_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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}/products') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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. @@ -45,17 +94,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_apis( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductCollection"] + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ProductCollection"]: """Lists all Products, which the API is part of. :param resource_group_name: The name of the resource group. @@ -82,43 +131,41 @@ def list_by_apis( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_apis.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_apis.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ProductCollection', pipeline_response) + deserialized = self._deserialize("ProductCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -131,12 +178,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_release_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_release_operations.py index 61fce57894aaa..a9d1a09290f7b 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 @@ -5,23 +5,294 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + api_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + api_id: str, + release_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + api_id: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + api_id: str, + release_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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,17 +316,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApiReleaseCollection"] + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ApiReleaseCollection"]: """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. @@ -75,7 +346,8 @@ def list_by_service( :param skip: Number of records to skip. :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 ApiReleaseCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiReleaseCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -84,43 +356,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApiReleaseCollection', pipeline_response) + deserialized = self._deserialize("ApiReleaseCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -133,26 +403,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - api_id, # type: str - release_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -174,55 +445,47 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace def get( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - release_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApiReleaseContract" + 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. @@ -244,58 +507,51 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiReleaseContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - release_id, # type: str - parameters, # type: "_models.ApiReleaseContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.ApiReleaseContract" + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + parameters: "_models.ApiReleaseContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.ApiReleaseContract": """Creates a new Release for the API. :param resource_group_name: The name of the resource group. @@ -322,70 +578,63 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiReleaseContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ApiReleaseContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - release_id, # type: str - if_match, # type: str - parameters, # type: "_models.ApiReleaseContract" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApiReleaseContract" + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + if_match: str, + parameters: "_models.ApiReleaseContract", + **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. @@ -412,63 +661,56 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiReleaseContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ApiReleaseContract') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiReleaseContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - release_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -493,39 +735,30 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 2b4d33e8fe0b9..4a4022ac65856 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 @@ -5,23 +5,72 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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, + api_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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}/revisions') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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. @@ -45,17 +94,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApiRevisionCollection"] + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ApiRevisionCollection"]: """Lists all revisions of an API. :param resource_group_name: The name of the resource group. @@ -73,7 +122,8 @@ def list_by_service( :param skip: Number of records to skip. :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 ApiRevisionCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiRevisionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -82,43 +132,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApiRevisionCollection', pipeline_response) + deserialized = self._deserialize("ApiRevisionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -131,12 +179,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_schema_operations.py index 8cbe44ecace1a..32efd7ae24b8b 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 @@ -5,25 +5,249 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_api_request( + resource_group_name: str, + service_name: str, + api_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + api_id: str, + schema_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request_initial( + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + schema_id: str, + subscription_id: str, + *, + if_match: str, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # 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') + + # 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. @@ -47,17 +271,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_api( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SchemaCollection"] + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SchemaCollection"]: """Get the schema configuration at the API level. :param resource_group_name: The name of the resource group. @@ -85,43 +309,41 @@ def list_by_api( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_api.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_api.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SchemaCollection', pipeline_response) + deserialized = self._deserialize("SchemaCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -134,26 +356,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - api_id, # type: str - schema_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -163,8 +386,8 @@ def get_entity_tag( :param api_id: API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param schema_id: Schema identifier within an API. Must be unique in the current API Management - service instance. + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. :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) @@ -176,55 +399,47 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'schemaId': self._serialize.url("schema_id", schema_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace def get( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - schema_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SchemaContract" + 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. @@ -234,8 +449,8 @@ def get( :param api_id: API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param schema_id: Schema identifier within an API. Must be unique in the current API Management - service instance. + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. :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) @@ -247,128 +462,112 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'schemaId': self._serialize.url("schema_id", schema_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SchemaContract', pipeline_response) 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 + def _create_or_update_initial( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - schema_id, # type: str - parameters, # type: "_models.SchemaContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SchemaContract"] + resource_group_name: str, + service_name: str, + api_id: str, + schema_id: str, + parameters: "_models.SchemaContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.SchemaContract"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SchemaContract"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'schemaId': self._serialize.url("schema_id", schema_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SchemaContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SchemaContract') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SchemaContract', pipeline_response) if response.status_code == 201: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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 + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - schema_id, # type: str - parameters, # type: "_models.SchemaContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SchemaContract"] + resource_group_name: str, + service_name: str, + api_id: str, + schema_id: str, + parameters: "_models.SchemaContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller["_models.SchemaContract"]: """Creates or updates schema configuration for the API. :param resource_group_name: The name of the resource group. @@ -378,8 +577,8 @@ def begin_create_or_update( :param api_id: API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param schema_id: Schema identifier within an API. Must be unique in the current API Management - service instance. + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. :type schema_id: str :param parameters: The schema contents to apply. :type parameters: ~azure.mgmt.apimanagement.models.SchemaContract @@ -388,15 +587,19 @@ def begin_create_or_update( :type if_match: 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. + :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) + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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', @@ -411,32 +614,24 @@ def begin_create_or_update( schema_id=schema_id, parameters=parameters, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', 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) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'schemaId': self._serialize.url("schema_id", schema_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -448,19 +643,20 @@ def get_long_running_output(pipeline_response): ) else: 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 + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - schema_id, # type: str - if_match, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + api_id: str, + schema_id: str, + if_match: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: """Deletes the schema configuration at the Api. :param resource_group_name: The name of the resource group. @@ -470,8 +666,8 @@ def delete( :param api_id: API revision identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param schema_id: Schema identifier within an API. Must be unique in the current API Management - service instance. + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. :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. @@ -488,41 +684,31 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'schemaId': self._serialize.url("schema_id", schema_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + force=force, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 eb2003ce33ca6..17b0958bb6afd 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 @@ -5,23 +5,244 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + api_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + api_id: str, + tag_description_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + api_id: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,17 +266,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TagDescriptionCollection"] + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.TagDescriptionCollection"]: """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. @@ -76,7 +297,8 @@ def list_by_service( :param skip: Number of records to skip. :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 cls(response) + :return: An iterator like instance of either TagDescriptionCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagDescriptionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -85,43 +307,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagDescriptionCollection', pipeline_response) + deserialized = self._deserialize("TagDescriptionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -134,26 +354,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - api_id, # type: str - tag_description_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -176,55 +397,47 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'tagDescriptionId': self._serialize.url("tag_description_id", tag_description_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace def get( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - tag_description_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.TagDescriptionContract" + 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. @@ -247,58 +460,51 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'tagDescriptionId': self._serialize.url("tag_description_id", tag_description_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagDescriptionContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - tag_description_id, # type: str - parameters, # type: "_models.TagDescriptionCreateParameters" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.TagDescriptionContract" + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + parameters: "_models.TagDescriptionCreateParameters", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.TagDescriptionContract": """Create/Update tag description in scope of the Api. :param resource_group_name: The name of the resource group. @@ -326,69 +532,62 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'tagDescriptionId': self._serialize.url("tag_description_id", tag_description_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagDescriptionCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TagDescriptionCreateParameters') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_description_id=tag_description_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - tag_description_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + if_match: str, + **kwargs: Any + ) -> None: """Delete tag description for the Api. :param resource_group_name: The name of the resource group. @@ -414,39 +613,30 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'tagDescriptionId': self._serialize.url("tag_description_id", tag_description_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_description_id=tag_description_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 62e8345b13b22..af55aacf9bef4 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 @@ -5,23 +5,282 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + version_set_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + version_set_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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + version_set_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,16 +304,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApiVersionSetCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ApiVersionSetCollection"]: """Lists a collection of API Version Sets in the specified service instance. :param resource_group_name: The name of the resource group. @@ -69,7 +328,8 @@ def list_by_service( :param skip: Number of records to skip. :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 cls(response) + :return: An iterator like instance of either ApiVersionSetCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiVersionSetCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -78,42 +338,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApiVersionSetCollection', pipeline_response) + deserialized = self._deserialize("ApiVersionSetCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -126,25 +383,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - version_set_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -164,53 +422,45 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - version_set_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApiVersionSetContract" + 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. @@ -230,56 +480,49 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - version_set_id, # type: str - parameters, # type: "_models.ApiVersionSetContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.ApiVersionSetContract" + resource_group_name: str, + service_name: str, + version_set_id: str, + parameters: "_models.ApiVersionSetContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.ApiVersionSetContract": """Creates or Updates a Api Version Set. :param resource_group_name: The name of the resource group. @@ -304,68 +547,61 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiVersionSetContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ApiVersionSetContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - version_set_id, # type: str - if_match, # type: str - parameters, # type: "_models.ApiVersionSetUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.ApiVersionSetContract" + resource_group_name: str, + service_name: str, + version_set_id: str, + if_match: str, + parameters: "_models.ApiVersionSetUpdateParameters", + **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. @@ -390,61 +626,54 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ApiVersionSetUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - version_set_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -467,38 +696,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 05ed2efd3908a..5371788412f99 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 @@ -5,23 +5,319 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + authsid: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + authsid: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + authsid: 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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 + ) + + +def build_list_secrets_request( + resource_group_name: str, + service_name: str, + authsid: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}/listSecrets') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,16 +341,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AuthorizationServerCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.AuthorizationServerCollection"]: """Lists a collection of authorization servers defined within a service instance. :param resource_group_name: The name of the resource group. @@ -72,8 +368,10 @@ def list_by_service( :param skip: Number of records to skip. :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 cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AuthorizationServerCollection] + :return: An iterator like instance of either AuthorizationServerCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AuthorizationServerCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerCollection"] @@ -81,42 +379,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AuthorizationServerCollection', pipeline_response) + deserialized = self._deserialize("AuthorizationServerCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -129,25 +424,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - authsid, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -166,53 +462,45 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - authsid, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AuthorizationServerContract" + 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. @@ -231,56 +519,49 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - authsid, # type: str - parameters, # type: "_models.AuthorizationServerContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.AuthorizationServerContract" + resource_group_name: str, + service_name: str, + authsid: str, + parameters: "_models.AuthorizationServerContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.AuthorizationServerContract": """Creates new authorization server or updates an existing authorization server. :param resource_group_name: The name of the resource group. @@ -304,68 +585,61 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AuthorizationServerContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AuthorizationServerContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authsid=authsid, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - authsid, # type: str - if_match, # type: str - parameters, # type: "_models.AuthorizationServerUpdateContract" - **kwargs # type: Any - ): - # type: (...) -> "_models.AuthorizationServerContract" + resource_group_name: str, + service_name: str, + authsid: str, + if_match: str, + parameters: "_models.AuthorizationServerUpdateContract", + **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. @@ -389,61 +663,54 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AuthorizationServerUpdateContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AuthorizationServerUpdateContract') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authsid=authsid, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - authsid, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -465,35 +732,25 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -501,14 +758,15 @@ def delete( 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, # type: str - service_name, # type: str - authsid, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AuthorizationServerSecretsContract" + 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. @@ -527,42 +785,35 @@ def list_secrets( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_secrets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AuthorizationServerSecretsContract', pipeline_response) 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 + 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 0188edb8ff6af..f9a99417d3435 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 @@ -5,23 +5,328 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + backend_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + backend_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + backend_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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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 + ) + + +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 +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,16 +350,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BackendCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.BackendCollection"]: """Lists a collection of backends in the specified service instance. :param resource_group_name: The name of the resource group. @@ -81,42 +386,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BackendCollection', pipeline_response) + deserialized = self._deserialize("BackendCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -129,25 +431,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - backend_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -167,53 +470,45 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - backend_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BackendContract" + 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. @@ -233,56 +528,49 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('BackendContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - backend_id, # type: str - parameters, # type: "_models.BackendContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.BackendContract" + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: "_models.BackendContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.BackendContract": """Creates or Updates a backend. :param resource_group_name: The name of the resource group. @@ -307,68 +595,61 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BackendContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'BackendContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - backend_id, # type: str - if_match, # type: str - parameters, # type: "_models.BackendUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.BackendContract" + resource_group_name: str, + service_name: str, + backend_id: str, + if_match: str, + parameters: "_models.BackendUpdateParameters", + **kwargs: Any + ) -> "_models.BackendContract": """Updates an existing backend. :param resource_group_name: The name of the resource group. @@ -393,61 +674,54 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BackendUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('BackendContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - backend_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -470,35 +744,25 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -506,15 +770,16 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + + @distributed_trace def reconnect( self, - resource_group_name, # type: str - service_name, # type: str - backend_id, # type: str - parameters=None, # type: Optional["_models.BackendReconnectContract"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: Optional["_models.BackendReconnectContract"] = 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. @@ -537,45 +802,36 @@ def reconnect( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.reconnect.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'BackendReconnectContract') + _json = self._serialize.body(parameters, 'BackendReconnectContract') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _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, + content_type=content_type, + json=_json, + template_url=self.reconnect.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) 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 48edb10565876..2f93fcf0919b1 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 @@ -5,23 +5,279 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # 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) + 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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + cache_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + cache_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + cache_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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,15 +301,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.CacheCollection"] + resource_group_name: str, + service_name: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.CacheCollection"]: """Lists a collection of all external Caches in the specified service instance. :param resource_group_name: The name of the resource group. @@ -74,40 +330,37 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('CacheCollection', pipeline_response) + deserialized = self._deserialize("CacheCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,25 +373,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - cache_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -158,53 +412,45 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - cache_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CacheContract" + 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. @@ -224,56 +470,49 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CacheContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - cache_id, # type: str - parameters, # type: "_models.CacheContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.CacheContract" + resource_group_name: str, + service_name: str, + cache_id: str, + parameters: "_models.CacheContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.CacheContract": """Creates or updates an External Cache to be used in Api Management instance. :param resource_group_name: The name of the resource group. @@ -298,68 +537,61 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CacheContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CacheContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + cache_id=cache_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - cache_id, # type: str - if_match, # type: str - parameters, # type: "_models.CacheUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.CacheContract" + resource_group_name: str, + service_name: str, + cache_id: str, + if_match: str, + parameters: "_models.CacheUpdateParameters", + **kwargs: Any + ) -> "_models.CacheContract": """Updates the details of the cache specified by its identifier. :param resource_group_name: The name of the resource group. @@ -384,61 +616,54 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CacheUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CacheContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - cache_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -461,38 +686,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 328ada399671e..c8e86d9829195 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 @@ -5,23 +5,274 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + is_key_vault_refresh_failed: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + certificate_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + certificate_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + certificate_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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 + ) + + +def build_refresh_secret_request( + resource_group_name: str, + service_name: str, + certificate_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}/refreshSecret') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,17 +296,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - is_key_vault_refresh_failed=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.CertificateCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + is_key_vault_refresh_failed: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.CertificateCollection"]: """Lists a collection of all certificates in the specified service instance. :param resource_group_name: The name of the resource group. @@ -77,7 +328,8 @@ def list_by_service( entities which failed refresh. :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 CertificateCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.CertificateCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -86,44 +338,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if is_key_vault_refresh_failed is not None: - query_parameters['isKeyVaultRefreshFailed'] = self._serialize.query("is_key_vault_refresh_failed", is_key_vault_refresh_failed, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('CertificateCollection', pipeline_response) + deserialized = self._deserialize("CertificateCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -136,25 +385,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - certificate_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -174,53 +424,45 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - certificate_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateContract" + 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. @@ -240,56 +482,49 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CertificateContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - certificate_id, # type: str - parameters, # type: "_models.CertificateCreateOrUpdateParameters" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateContract" + resource_group_name: str, + service_name: str, + certificate_id: str, + parameters: "_models.CertificateCreateOrUpdateParameters", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.CertificateContract": """Creates or updates the certificate being used for authentication with the backend. :param resource_group_name: The name of the resource group. @@ -314,67 +549,60 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CertificateCreateOrUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - certificate_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -397,35 +625,25 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -433,14 +651,15 @@ def delete( 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, # type: str - service_name, # type: str - certificate_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateContract" + 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. @@ -460,42 +679,35 @@ def refresh_secret( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.refresh_secret.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CertificateContract', pipeline_response) 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 + 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 834ab75e14c31..321b5c4ad70f0 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 @@ -5,23 +5,225 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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 +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + content_type_id: str, + content_item_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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 + ) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,14 +247,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - content_type_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ContentItemCollection"] + resource_group_name: str, + service_name: str, + content_type_id: str, + **kwargs: Any + ) -> Iterable["_models.ContentItemCollection"]: """Lists developer portal's content items specified by the provided content type. :param resource_group_name: The name of the resource group. @@ -62,7 +264,8 @@ def list_by_service( :param content_type_id: Content type identifier. :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 ContentItemCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ContentItemCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -71,37 +274,35 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ContentItemCollection', pipeline_response) + deserialized = self._deserialize("ContentItemCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -114,26 +315,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - content_type_id, # type: str - content_item_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -155,55 +357,47 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), - 'contentItemId': self._serialize.url("content_item_id", content_item_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace def get( self, - resource_group_name, # type: str - service_name, # type: str - content_type_id, # type: str - content_item_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ContentItemContract" + 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. @@ -224,57 +418,50 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), - 'contentItemId': self._serialize.url("content_item_id", content_item_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ContentItemContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - content_type_id, # type: str - content_item_id, # type: str - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.ContentItemContract" + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.ContentItemContract": """Creates a new developer portal's content item specified by the provided content type. :param resource_group_name: The name of the resource group. @@ -298,64 +485,57 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), - 'contentItemId': self._serialize.url("content_item_id", content_item_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + content_item_id=content_item_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - content_type_id, # type: str - content_item_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + if_match: str, + **kwargs: Any + ) -> None: """Removes the specified developer portal's content item. :param resource_group_name: The name of the resource group. @@ -379,39 +559,30 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), - 'contentItemId': self._serialize.url("content_item_id", content_item_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + content_item_id=content_item_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 0432ae10d0609..1dbacaf2c703b 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 @@ -5,23 +5,178 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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 +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_get_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + content_type_id: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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 + ) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + content_type_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,13 +200,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ContentTypeCollection"] + resource_group_name: str, + service_name: str, + **kwargs: Any + ) -> Iterable["_models.ContentTypeCollection"]: """Lists the developer portal's content types. Content types describe content items' properties, validation rules, and constraints. @@ -60,7 +215,8 @@ def list_by_service( :param service_name: The name of the API Management service. :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 ContentTypeCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ContentTypeCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -69,36 +225,33 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ContentTypeCollection', pipeline_response) + deserialized = self._deserialize("ContentTypeCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,25 +264,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - content_type_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ContentTypeContract" + 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. @@ -149,55 +303,48 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ContentTypeContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - content_type_id, # type: str - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.ContentTypeContract" + resource_group_name: str, + service_name: str, + content_type_id: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.ContentTypeContract": """Creates or updates the developer portal's content type. Content types describe content items' properties, validation rules, and constraints. Custom content types' identifiers need to start with the ``c-`` prefix. Built-in content types can't be modified. @@ -221,62 +368,55 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - content_type_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -300,38 +440,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 e26b0d3b0bc36..e19f0eca14928 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 @@ -5,22 +5,223 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_entity_tag_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_update_request( + resource_group_name: str, + service_name: 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] + + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_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 +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_list_secrets_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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/listSecrets') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -44,13 +245,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_entity_tag( self, - resource_group_name, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -67,51 +268,43 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PortalDelegationSettings" + 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. @@ -128,54 +321,47 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PortalDelegationSettings', pipeline_response) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - if_match, # type: str - parameters, # type: "_models.PortalDelegationSettings" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + if_match: str, + parameters: "_models.PortalDelegationSettings", + **kwargs: Any + ) -> None: """Update Delegation settings. :param resource_group_name: The name of the resource group. @@ -197,39 +383,29 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PortalDelegationSettings') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PortalDelegationSettings') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -237,15 +413,16 @@ def update( update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - parameters, # type: "_models.PortalDelegationSettings" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.PortalDelegationSettings" + resource_group_name: str, + service_name: str, + parameters: "_models.PortalDelegationSettings", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.PortalDelegationSettings": """Create or Update Delegation settings. :param resource_group_name: The name of the resource group. @@ -267,40 +444,29 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PortalDelegationSettings') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PortalDelegationSettings') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PortalDelegationSettings', pipeline_response) @@ -309,15 +475,17 @@ def create_or_update( 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 + + @distributed_trace def list_secrets( self, - resource_group_name, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PortalSettingValidationKeyContract" + 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. @@ -334,33 +502,23 @@ def list_secrets( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_secrets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PortalSettingValidationKeyContract', pipeline_response) @@ -369,4 +527,6 @@ def list_secrets( 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 + 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 1aa702e0791eb..351c58e95be56 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 @@ -5,25 +5,128 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_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}') + path_format_arguments = { + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "location": _SERIALIZER.url("location", location, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_purge_request_initial( + 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}') + path_format_arguments = { + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "location": _SERIALIZER.url("location", location, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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 DeletedServicesOperations(object): """DeletedServicesOperations operations. @@ -47,16 +150,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DeletedServicesCollection"] + **kwargs: Any + ) -> Iterable["_models.DeletedServicesCollection"]: """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 cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.DeletedServicesCollection] + :return: An iterator like instance of either DeletedServicesCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.DeletedServicesCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedServicesCollection"] @@ -64,34 +169,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DeletedServicesCollection', pipeline_response) + deserialized = self._deserialize("DeletedServicesCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -104,24 +204,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices'} # type: ignore + @distributed_trace def get_by_name( self, - service_name, # type: str - location, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DeletedServiceContract" + 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. @@ -138,33 +239,23 @@ def get_by_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_by_name.metadata['url'] # type: ignore - path_format_arguments = { - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'location': self._serialize.url("location", location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DeletedServiceContract', pipeline_response) @@ -173,48 +264,38 @@ def get_by_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}'} # type: ignore + def _purge_initial( self, - service_name, # type: str - location, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.DeletedServiceContract"] + service_name: str, + location: str, + **kwargs: Any + ) -> Optional["_models.DeletedServiceContract"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeletedServiceContract"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._purge_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'location': self._serialize.url("location", location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_purge_request_initial( + service_name=service_name, + subscription_id=self._config.subscription_id, + location=location, + template_url=self._purge_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 202: @@ -224,15 +305,17 @@ def _purge_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _purge_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}'} # type: ignore + + @distributed_trace def begin_purge( self, - service_name, # type: str - location, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DeletedServiceContract"] + service_name: str, + location: str, + **kwargs: Any + ) -> LROPoller["_models.DeletedServiceContract"]: """Purges Api Management Service (deletes it with no option to undelete). :param service_name: The name of the API Management service. @@ -241,15 +324,18 @@ def begin_purge( :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. - :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. + :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 None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :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 DeletedServiceContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.DeletedServiceContract] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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', @@ -263,24 +349,17 @@ def begin_purge( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DeletedServiceContract', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'location': self._serialize.url("location", location, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -292,4 +371,5 @@ def get_long_running_output(pipeline_response): ) else: 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 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 07a10ac114d98..54ebbdb8a37ca 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 @@ -5,23 +5,282 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + diagnostic_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + diagnostic_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + diagnostic_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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + diagnostic_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,16 +304,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DiagnosticCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.DiagnosticCollection"]: """Lists all diagnostics of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -70,7 +329,8 @@ def list_by_service( :param skip: Number of records to skip. :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 DiagnosticCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.DiagnosticCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -79,42 +339,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DiagnosticCollection', pipeline_response) + deserialized = self._deserialize("DiagnosticCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -127,25 +384,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - diagnostic_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -165,53 +423,45 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - diagnostic_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DiagnosticContract" + 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. @@ -231,56 +481,49 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - diagnostic_id, # type: str - parameters, # type: "_models.DiagnosticContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.DiagnosticContract" + resource_group_name: str, + service_name: str, + diagnostic_id: str, + parameters: "_models.DiagnosticContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.DiagnosticContract": """Creates a new Diagnostic or updates an existing one. :param resource_group_name: The name of the resource group. @@ -305,68 +548,61 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DiagnosticContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DiagnosticContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - diagnostic_id, # type: str - if_match, # type: str - parameters, # type: "_models.DiagnosticContract" - **kwargs # type: Any - ): - # type: (...) -> "_models.DiagnosticContract" + resource_group_name: str, + service_name: str, + diagnostic_id: str, + if_match: str, + parameters: "_models.DiagnosticContract", + **kwargs: Any + ) -> "_models.DiagnosticContract": """Updates the details of the Diagnostic specified by its identifier. :param resource_group_name: The name of the resource group. @@ -391,61 +627,54 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DiagnosticContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DiagnosticContract') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - diagnostic_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -468,38 +697,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 72c2d4d59c28f..c5fadd90b3a6e 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 @@ -5,23 +5,282 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + template_name: Union[str, "_models.TemplateName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + template_name: Union[str, "_models.TemplateName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + template_name: Union[str, "_models.TemplateName"], + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,16 +304,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EmailTemplateCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.EmailTemplateCollection"]: """Gets all email templates. :param resource_group_name: The name of the resource group. @@ -70,7 +329,8 @@ def list_by_service( :param skip: Number of records to skip. :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 cls(response) + :return: An iterator like instance of either EmailTemplateCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.EmailTemplateCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -79,42 +339,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EmailTemplateCollection', pipeline_response) + deserialized = self._deserialize("EmailTemplateCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -127,25 +384,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - template_name, # type: Union[str, "_models.TemplateName"] - **kwargs # type: Any - ): - # type: (...) -> bool + resource_group_name: str, + service_name: str, + template_name: Union[str, "_models.TemplateName"], + **kwargs: Any + ) -> bool: """Gets the entity state (Etag) version of the email template specified by its identifier. :param resource_group_name: The name of the resource group. @@ -164,53 +422,45 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("template_name", template_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - template_name, # type: Union[str, "_models.TemplateName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.EmailTemplateContract" + resource_group_name: str, + service_name: str, + template_name: Union[str, "_models.TemplateName"], + **kwargs: Any + ) -> "_models.EmailTemplateContract": """Gets the details of the email template specified by its identifier. :param resource_group_name: The name of the resource group. @@ -229,56 +479,49 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("template_name", template_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('EmailTemplateContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - template_name, # type: Union[str, "_models.TemplateName"] - parameters, # type: "_models.EmailTemplateUpdateParameters" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.EmailTemplateContract" + resource_group_name: str, + service_name: str, + template_name: Union[str, "_models.TemplateName"], + parameters: "_models.EmailTemplateUpdateParameters", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.EmailTemplateContract": """Updates an Email Template. :param resource_group_name: The name of the resource group. @@ -302,41 +545,30 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("template_name", template_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'EmailTemplateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -349,18 +581,20 @@ def create_or_update( 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - template_name, # type: Union[str, "_models.TemplateName"] - if_match, # type: str - parameters, # type: "_models.EmailTemplateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.EmailTemplateContract" + resource_group_name: str, + service_name: str, + template_name: Union[str, "_models.TemplateName"], + if_match: str, + parameters: "_models.EmailTemplateUpdateParameters", + **kwargs: Any + ) -> "_models.EmailTemplateContract": """Updates API Management email template. :param resource_group_name: The name of the resource group. @@ -384,61 +618,54 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("template_name", template_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'EmailTemplateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('EmailTemplateContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - template_name, # type: Union[str, "_models.TemplateName"] - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + template_name: Union[str, "_models.TemplateName"], + if_match: str, + **kwargs: Any + ) -> None: """Reset the Email Template to default template provided by the API Management service instance. :param resource_group_name: The name of the resource group. @@ -460,38 +687,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("template_name", template_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 33f740d3b7732..fe783314a0a7d 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 @@ -5,23 +5,199 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + gateway_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_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 +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_delete_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,17 +221,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - gateway_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApiCollection"] + resource_group_name: str, + service_name: str, + gateway_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ApiCollection"]: """Lists a collection of the APIs associated with a gateway. :param resource_group_name: The name of the resource group. @@ -83,43 +259,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApiCollection', pipeline_response) + deserialized = self._deserialize("ApiCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -132,26 +306,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - gateway_id, # type: str - api_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -173,56 +348,48 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - gateway_id, # type: str - api_id, # type: str - parameters=None, # type: Optional["_models.AssociationContract"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ApiContract" + resource_group_name: str, + service_name: str, + gateway_id: str, + api_id: str, + parameters: Optional["_models.AssociationContract"] = None, + **kwargs: Any + ) -> "_models.ApiContract": """Adds an API to the specified Gateway. :param resource_group_name: The name of the resource group. @@ -246,43 +413,33 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: - body_content = self._serialize.body(parameters, 'AssociationContract') + _json = self._serialize.body(parameters, 'AssociationContract') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -295,17 +452,19 @@ def create_or_update( 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - gateway_id, # type: str - api_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -327,38 +486,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 f249941ab9b7d..b85d3827c3477 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 @@ -5,23 +5,244 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + gateway_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + gateway_id: str, + certificate_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + gateway_id: str, + certificate_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + gateway_id: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + gateway_id: str, + certificate_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,17 +266,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - gateway_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GatewayCertificateAuthorityCollection"] + resource_group_name: str, + service_name: str, + gateway_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.GatewayCertificateAuthorityCollection"]: """Lists the collection of Certificate Authorities for the specified Gateway entity. :param resource_group_name: The name of the resource group. @@ -74,8 +295,10 @@ def list_by_service( :param skip: Number of records to skip. :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) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityCollection] + :return: An iterator like instance of either GatewayCertificateAuthorityCollection or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCertificateAuthorityCollection"] @@ -83,43 +306,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('GatewayCertificateAuthorityCollection', pipeline_response) + deserialized = self._deserialize("GatewayCertificateAuthorityCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -132,26 +353,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - gateway_id, # type: str - certificate_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -174,55 +396,47 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'certificateId': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace def get( self, - resource_group_name, # type: str - service_name, # type: str - gateway_id, # type: str - certificate_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GatewayCertificateAuthorityContract" + 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. @@ -245,58 +459,51 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'certificateId': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayCertificateAuthorityContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - gateway_id, # type: str - certificate_id, # type: str - parameters, # type: "_models.GatewayCertificateAuthorityContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.GatewayCertificateAuthorityContract" + resource_group_name: str, + service_name: str, + gateway_id: str, + certificate_id: str, + parameters: "_models.GatewayCertificateAuthorityContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.GatewayCertificateAuthorityContract": """Assign Certificate entity to Gateway entity as Certificate Authority. :param resource_group_name: The name of the resource group. @@ -324,69 +531,62 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'certificateId': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GatewayCertificateAuthorityContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GatewayCertificateAuthorityContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - gateway_id, # type: str - certificate_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + gateway_id: str, + certificate_id: str, + if_match: str, + **kwargs: Any + ) -> None: """Remove relationship between Certificate Authority and Gateway entity. :param resource_group_name: The name of the resource group. @@ -412,39 +612,30 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'certificateId': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 18430a5b9d74e..7305625bbed5a 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 @@ -5,23 +5,244 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + gateway_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + gateway_id: str, + hc_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + gateway_id: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + gateway_id: str, + hc_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,17 +266,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - gateway_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GatewayHostnameConfigurationCollection"] + resource_group_name: str, + service_name: str, + gateway_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.GatewayHostnameConfigurationCollection"]: """Lists the collection of hostname configurations for the specified gateway. :param resource_group_name: The name of the resource group. @@ -75,8 +296,10 @@ def list_by_service( :param skip: Number of records to skip. :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) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationCollection] + :return: An iterator like instance of either GatewayHostnameConfigurationCollection or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayHostnameConfigurationCollection"] @@ -84,43 +307,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('GatewayHostnameConfigurationCollection', pipeline_response) + deserialized = self._deserialize("GatewayHostnameConfigurationCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -133,26 +354,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - gateway_id, # type: str - hc_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -176,55 +398,47 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'hcId': self._serialize.url("hc_id", hc_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace def get( self, - resource_group_name, # type: str - service_name, # type: str - gateway_id, # type: str - hc_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GatewayHostnameConfigurationContract" + 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. @@ -247,58 +461,51 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'hcId': self._serialize.url("hc_id", hc_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayHostnameConfigurationContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - gateway_id, # type: str - hc_id, # type: str - parameters, # type: "_models.GatewayHostnameConfigurationContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.GatewayHostnameConfigurationContract" + resource_group_name: str, + service_name: str, + gateway_id: str, + hc_id: str, + parameters: "_models.GatewayHostnameConfigurationContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.GatewayHostnameConfigurationContract": """Creates of updates hostname configuration for a Gateway. :param resource_group_name: The name of the resource group. @@ -326,69 +533,62 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'hcId': self._serialize.url("hc_id", hc_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GatewayHostnameConfigurationContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GatewayHostnameConfigurationContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + hc_id=hc_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - gateway_id, # type: str - hc_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -414,39 +614,30 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'hcId': self._serialize.url("hc_id", hc_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + hc_id=hc_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 0514066a16e7b..85e5aa5ed230e 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 @@ -5,23 +5,411 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + gateway_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + gateway_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + gateway_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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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 + ) + + +def build_list_keys_request( + resource_group_name: str, + service_name: str, + gateway_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}/listKeys') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_regenerate_key_request( + resource_group_name: str, + service_name: str, + gateway_id: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_generate_token_request( + resource_group_name: str, + service_name: str, + gateway_id: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,16 +433,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GatewayCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.GatewayCollection"]: """Lists a collection of gateways registered with service instance. :param resource_group_name: The name of the resource group. @@ -82,42 +470,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('GatewayCollection', pipeline_response) + deserialized = self._deserialize("GatewayCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -130,25 +515,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - gateway_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -168,53 +554,45 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - gateway_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GatewayContract" + 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. @@ -234,56 +612,49 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - gateway_id, # type: str - parameters, # type: "_models.GatewayContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.GatewayContract" + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: "_models.GatewayContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.GatewayContract": """Creates or updates a Gateway to be used in Api Management instance. :param resource_group_name: The name of the resource group. @@ -308,68 +679,61 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GatewayContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GatewayContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - gateway_id, # type: str - if_match, # type: str - parameters, # type: "_models.GatewayContract" - **kwargs # type: Any - ): - # type: (...) -> "_models.GatewayContract" + resource_group_name: str, + service_name: str, + gateway_id: str, + if_match: str, + parameters: "_models.GatewayContract", + **kwargs: Any + ) -> "_models.GatewayContract": """Updates the details of the gateway specified by its identifier. :param resource_group_name: The name of the resource group. @@ -394,61 +758,54 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GatewayContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GatewayContract') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - gateway_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -471,35 +828,25 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -507,14 +854,15 @@ def delete( 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, # type: str - service_name, # type: str - gateway_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GatewayKeysContract" + 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. @@ -534,55 +882,48 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayKeysContract', pipeline_response) 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 + + @distributed_trace def regenerate_key( self, - resource_group_name, # type: str - service_name, # type: str - gateway_id, # type: str - parameters, # type: "_models.GatewayKeyRegenerationRequestContract" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: "_models.GatewayKeyRegenerationRequestContract", + **kwargs: Any + ) -> None: """Regenerates specified gateway key invalidating any tokens created with it. :param resource_group_name: The name of the resource group. @@ -604,39 +945,29 @@ def regenerate_key( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GatewayKeyRegenerationRequestContract') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + 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, + content_type=content_type, + json=_json, + template_url=self.regenerate_key.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GatewayKeyRegenerationRequestContract') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -644,15 +975,16 @@ def regenerate_key( regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/regenerateKey'} # type: ignore + + @distributed_trace def generate_token( self, - resource_group_name, # type: str - service_name, # type: str - gateway_id, # type: str - parameters, # type: "_models.GatewayTokenRequestContract" - **kwargs # type: Any - ): - # type: (...) -> "_models.GatewayTokenContract" + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: "_models.GatewayTokenRequestContract", + **kwargs: Any + ) -> "_models.GatewayTokenContract": """Gets the Shared Access Authorization Token for the gateway. :param resource_group_name: The name of the resource group. @@ -674,39 +1006,29 @@ def generate_token( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.generate_token.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GatewayTokenRequestContract') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + 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, + content_type=content_type, + json=_json, + template_url=self.generate_token.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GatewayTokenRequestContract') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GatewayTokenContract', pipeline_response) @@ -715,4 +1037,6 @@ def generate_token( 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 + 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 new file mode 100644 index 0000000000000..2f8a6ca73524a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_global_schema_operations.py @@ -0,0 +1,670 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 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.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 +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + schema_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + schema_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request_initial( + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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: ~azure.mgmt.apimanagement.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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.GlobalSchemaCollection"]: + """Lists a collection of schemas registered with service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :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 + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GlobalSchemaCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GlobalSchemaCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + template_url=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GlobalSchemaCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + 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: + """Gets the entity state (Etag) version of the Schema specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. + :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) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + + if cls: + return cls(pipeline_response, None, response_headers) + return 200 <= response.status_code <= 299 + + 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": + """Gets the details of the Schema specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. + :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: ~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 + } + error_map.update(kwargs.pop('error_map', {})) + + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('GlobalSchemaContract', pipeline_response) + + 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 + + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + schema_id: str, + parameters: "_models.GlobalSchemaContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.GlobalSchemaContract"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GlobalSchemaContract"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GlobalSchemaContract') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + + deserialized = None + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('GlobalSchemaContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + 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 + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + schema_id: str, + parameters: "_models.GlobalSchemaContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller["_models.GlobalSchemaContract"]: + """Creates new or updates existing specified Schema of the API Management service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. + :type schema_id: str + :param parameters: Create or update parameters. + :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. + :type if_match: 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 + """ + 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] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + schema_id=schema_id, + parameters=parameters, + if_match=if_match, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + 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) + 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 cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + 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 + + @distributed_trace + def delete( + self, + resource_group_name: str, + service_name: str, + schema_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes specific Schema. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param schema_id: Schema id identifier. Must be unique in the current API Management service + instance. + :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. + :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) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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 37476af9d0b81..5e44026f71e98 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 @@ -5,23 +5,282 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + group_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + group_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + group_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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,16 +304,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GroupCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.GroupCollection"]: """Lists a collection of groups defined within a service instance. :param resource_group_name: The name of the resource group. @@ -82,42 +341,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('GroupCollection', pipeline_response) + deserialized = self._deserialize("GroupCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -130,25 +386,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - group_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -168,53 +425,45 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - group_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GroupContract" + 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. @@ -234,56 +483,49 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GroupContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - group_id, # type: str - parameters, # type: "_models.GroupCreateParameters" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.GroupContract" + resource_group_name: str, + service_name: str, + group_id: str, + parameters: "_models.GroupCreateParameters", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.GroupContract": """Creates or Updates a group. :param resource_group_name: The name of the resource group. @@ -308,68 +550,61 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GroupCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - group_id, # type: str - if_match, # type: str - parameters, # type: "_models.GroupUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.GroupContract" + resource_group_name: str, + service_name: str, + group_id: str, + if_match: str, + parameters: "_models.GroupUpdateParameters", + **kwargs: Any + ) -> "_models.GroupContract": """Updates the details of the group specified by its identifier. :param resource_group_name: The name of the resource group. @@ -394,61 +629,54 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GroupUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GroupContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - group_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -471,38 +699,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 0a632ff2667c6..0c8d8d333ee8d 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 @@ -5,23 +5,189 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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, + group_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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}/users') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_check_entity_exists_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,17 +211,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - service_name, # type: str - group_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UserCollection"] + resource_group_name: str, + service_name: str, + group_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.UserCollection"]: """Lists a collection of user entities associated with the group. :param resource_group_name: The name of the resource group. @@ -88,43 +254,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UserCollection', pipeline_response) + deserialized = self._deserialize("UserCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -137,26 +301,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - group_id, # type: str - user_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -178,52 +343,43 @@ def check_entity_exists( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.check_entity_exists.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: 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 + + @distributed_trace def create( self, - resource_group_name, # type: str - service_name, # type: str - group_id, # type: str - user_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.UserContract" + 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. @@ -245,35 +401,25 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -286,17 +432,19 @@ def create( 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - group_id, # type: str - user_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -318,38 +466,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 5ce3a2a103049..883dcc240eaae 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 @@ -5,23 +5,309 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, "_models.IdentityProviderType"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + identity_provider_name: Union[str, "_models.IdentityProviderType"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, "_models.IdentityProviderType"], + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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 + ) + + +def build_list_secrets_request( + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, "_models.IdentityProviderType"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}/listSecrets') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,13 +331,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IdentityProviderList"] + resource_group_name: str, + service_name: str, + **kwargs: Any + ) -> Iterable["_models.IdentityProviderList"]: """Lists a collection of Identity Provider configured in the specified service instance. :param resource_group_name: The name of the resource group. @@ -59,7 +345,8 @@ def list_by_service( :param service_name: The name of the API Management service. :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 cls(response) + :return: An iterator like instance of either IdentityProviderList or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IdentityProviderList] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -68,36 +355,33 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IdentityProviderList', pipeline_response) + deserialized = self._deserialize("IdentityProviderList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,25 +394,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - identity_provider_name, # type: Union[str, "_models.IdentityProviderType"] - **kwargs # type: Any - ): - # type: (...) -> bool + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, "_models.IdentityProviderType"], + **kwargs: Any + ) -> bool: """Gets the entity state (Etag) version of the identityProvider specified by its identifier. :param resource_group_name: The name of the resource group. @@ -147,53 +432,45 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - identity_provider_name, # type: Union[str, "_models.IdentityProviderType"] - **kwargs # type: Any - ): - # type: (...) -> "_models.IdentityProviderContract" + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, "_models.IdentityProviderType"], + **kwargs: Any + ) -> "_models.IdentityProviderContract": """Gets the configuration details of the identity Provider configured in specified service instance. @@ -213,56 +490,49 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IdentityProviderContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - identity_provider_name, # type: Union[str, "_models.IdentityProviderType"] - parameters, # type: "_models.IdentityProviderCreateContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.IdentityProviderContract" + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, "_models.IdentityProviderType"], + parameters: "_models.IdentityProviderCreateContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.IdentityProviderContract": """Creates or Updates the IdentityProvider configuration. :param resource_group_name: The name of the resource group. @@ -286,68 +556,61 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'IdentityProviderCreateContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'IdentityProviderCreateContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + identity_provider_name=identity_provider_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - identity_provider_name, # type: Union[str, "_models.IdentityProviderType"] - if_match, # type: str - parameters, # type: "_models.IdentityProviderUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.IdentityProviderContract" + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, "_models.IdentityProviderType"], + if_match: str, + parameters: "_models.IdentityProviderUpdateParameters", + **kwargs: Any + ) -> "_models.IdentityProviderContract": """Updates an existing IdentityProvider configuration. :param resource_group_name: The name of the resource group. @@ -371,61 +634,54 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'IdentityProviderUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IdentityProviderContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - identity_provider_name, # type: Union[str, "_models.IdentityProviderType"] - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, "_models.IdentityProviderType"], + if_match: str, + **kwargs: Any + ) -> None: """Deletes the specified identity provider configuration. :param resource_group_name: The name of the resource group. @@ -447,35 +703,25 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -483,14 +729,15 @@ def delete( 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, # type: str - service_name, # type: str - identity_provider_name, # type: Union[str, "_models.IdentityProviderType"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ClientSecretContract" + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, "_models.IdentityProviderType"], + **kwargs: Any + ) -> "_models.ClientSecretContract": """Gets the client secret details of the Identity Provider. :param resource_group_name: The name of the resource group. @@ -509,42 +756,35 @@ def list_secrets( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_secrets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ClientSecretContract', pipeline_response) 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 + 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 fa3b7907de74b..72c0d4611f292 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 @@ -5,23 +5,107 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace 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') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_request( + resource_group_name: str, + service_name: str, + issue_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues/{issueId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,16 +129,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IssueCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.IssueCollection"]: """Lists a collection of issues in the specified service instance. :param resource_group_name: The name of the resource group. @@ -84,42 +168,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IssueCollection', pipeline_response) + deserialized = self._deserialize("IssueCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -132,25 +213,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - issue_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.IssueContract" + 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. @@ -170,42 +252,35 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueContract', pipeline_response) 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 + 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 bcd93ad4e2b93..46b4179c57b93 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 @@ -5,23 +5,282 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + logger_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + logger_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + logger_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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,16 +304,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.LoggerCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.LoggerCollection"]: """Lists a collection of loggers in the specified service instance. :param resource_group_name: The name of the resource group. @@ -82,42 +341,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('LoggerCollection', pipeline_response) + deserialized = self._deserialize("LoggerCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -130,25 +386,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - logger_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -167,53 +424,45 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - logger_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.LoggerContract" + 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. @@ -232,56 +481,49 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('LoggerContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - logger_id, # type: str - parameters, # type: "_models.LoggerContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.LoggerContract" + resource_group_name: str, + service_name: str, + logger_id: str, + parameters: "_models.LoggerContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.LoggerContract": """Creates or Updates a logger. :param resource_group_name: The name of the resource group. @@ -305,68 +547,61 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'LoggerContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'LoggerContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - logger_id, # type: str - if_match, # type: str - parameters, # type: "_models.LoggerUpdateContract" - **kwargs # type: Any - ): - # type: (...) -> "_models.LoggerContract" + resource_group_name: str, + service_name: str, + logger_id: str, + if_match: str, + parameters: "_models.LoggerUpdateContract", + **kwargs: Any + ) -> "_models.LoggerContract": """Updates an existing logger. :param resource_group_name: The name of the resource group. @@ -390,61 +625,54 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'LoggerUpdateContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('LoggerContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - logger_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -466,38 +694,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 6b9da0738e42a..716117ba7666f 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 @@ -5,25 +5,361 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + is_key_vault_refresh_failed: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$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') + + # 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_get_entity_tag_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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + named_value_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request_initial( + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + named_value_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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 + ) + + +def build_list_value_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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/listValue') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_refresh_secret_request_initial( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -47,17 +383,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - is_key_vault_refresh_failed=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NamedValueCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + is_key_vault_refresh_failed: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.NamedValueCollection"]: """Lists a collection of named values defined within a service instance. :param resource_group_name: The name of the resource group. @@ -78,7 +414,8 @@ def list_by_service( entities which failed refresh. :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 NamedValueCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.NamedValueCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -87,44 +424,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if is_key_vault_refresh_failed is not None: - query_parameters['isKeyVaultRefreshFailed'] = self._serialize.query("is_key_vault_refresh_failed", is_key_vault_refresh_failed, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NamedValueCollection', pipeline_response) + deserialized = self._deserialize("NamedValueCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -137,25 +471,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - named_value_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -174,53 +509,45 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - named_value_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.NamedValueContract" + 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. @@ -239,124 +566,108 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) 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 + def _create_or_update_initial( self, - resource_group_name, # type: str - service_name, # type: str - named_value_id, # type: str - parameters, # type: "_models.NamedValueCreateContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.NamedValueContract"] + resource_group_name: str, + service_name: str, + named_value_id: str, + parameters: "_models.NamedValueCreateContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.NamedValueContract"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.NamedValueContract"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'NamedValueCreateContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'NamedValueCreateContract') + + request = build_create_or_update_request_initial( + 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, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) if response.status_code == 201: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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 + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - named_value_id, # type: str - parameters, # type: "_models.NamedValueCreateContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.NamedValueContract"] + resource_group_name: str, + service_name: str, + named_value_id: str, + parameters: "_models.NamedValueCreateContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller["_models.NamedValueContract"]: """Creates or updates named value. :param resource_group_name: The name of the resource group. @@ -372,15 +683,19 @@ def begin_create_or_update( :type if_match: 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. + :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) + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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', @@ -394,31 +709,24 @@ def begin_create_or_update( named_value_id=named_value_id, parameters=parameters, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', 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) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -430,81 +738,73 @@ def get_long_running_output(pipeline_response): ) else: 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 def _update_initial( self, - resource_group_name, # type: str - service_name, # type: str - named_value_id, # type: str - if_match, # type: str - parameters, # type: "_models.NamedValueUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.NamedValueContract"] + resource_group_name: str, + service_name: str, + named_value_id: str, + if_match: str, + parameters: "_models.NamedValueUpdateParameters", + **kwargs: Any + ) -> Optional["_models.NamedValueContract"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.NamedValueContract"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'NamedValueUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'NamedValueUpdateParameters') + + request = build_update_request_initial( + 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, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) if 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 + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - service_name, # type: str - named_value_id, # type: str - if_match, # type: str - parameters, # type: "_models.NamedValueUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.NamedValueContract"] + resource_group_name: str, + service_name: str, + named_value_id: str, + if_match: str, + parameters: "_models.NamedValueUpdateParameters", + **kwargs: Any + ) -> LROPoller["_models.NamedValueContract"]: """Updates the specific named value. :param resource_group_name: The name of the resource group. @@ -520,15 +820,19 @@ def begin_update( :type parameters: ~azure.mgmt.apimanagement.models.NamedValueUpdateParameters :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. + :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) + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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', @@ -542,31 +846,24 @@ def begin_update( named_value_id=named_value_id, if_match=if_match, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', 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) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -578,17 +875,18 @@ def get_long_running_output(pipeline_response): ) else: 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 + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - named_value_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -610,35 +908,25 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -646,14 +934,15 @@ def delete( 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, # type: str - service_name, # type: str - named_value_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.NamedValueSecretContract" + 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. @@ -672,109 +961,93 @@ def list_value( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_value.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueSecretContract', pipeline_response) 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 + def _refresh_secret_initial( self, - resource_group_name, # type: str - service_name, # type: str - named_value_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.NamedValueContract"] + 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"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._refresh_secret_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_refresh_secret_request_initial( + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) if 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 + + @distributed_trace def begin_refresh_secret( self, - resource_group_name, # type: str - service_name, # type: str - named_value_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.NamedValueContract"] + 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. @@ -785,15 +1058,18 @@ def begin_refresh_secret( :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. - :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. + :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) + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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', @@ -808,28 +1084,20 @@ def begin_refresh_secret( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', 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) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -841,4 +1109,5 @@ def get_long_running_output(pipeline_response): ) else: 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 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 fb1de731f5d66..7c3a71e23df93 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 @@ -5,22 +5,96 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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 +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', 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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_list_by_location_request( + subscription_id: str, + resource_group_name: str, + service_name: str, + location_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/locations/{locationName}/networkstatus') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', 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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -44,13 +118,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> List["_models.NetworkStatusContractByLocation"] + 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. @@ -69,33 +143,23 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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 = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('[NetworkStatusContractByLocation]', pipeline_response) @@ -104,16 +168,18 @@ def list_by_service( return cls(pipeline_response, deserialized, {}) return deserialized + 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, # type: str - service_name, # type: str - location_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkStatusContract" + 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. @@ -135,34 +201,24 @@ def list_by_location( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_location.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("location_name", location_name, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkStatusContract', pipeline_response) @@ -171,4 +227,6 @@ def list_by_location( 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 + 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 0670a253a1cad..0938088eb6bd1 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 @@ -5,23 +5,145 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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, + *, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # 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) + 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') + + # 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_get_request( + resource_group_name: str, + service_name: str, + notification_name: Union[str, "_models.NotificationName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + notification_name: Union[str, "_models.NotificationName"], + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,15 +167,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NotificationCollection"] + resource_group_name: str, + service_name: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.NotificationCollection"]: """Lists a collection of properties defined within a service instance. :param resource_group_name: The name of the resource group. @@ -65,7 +187,8 @@ def list_by_service( :param skip: Number of records to skip. :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 cls(response) + :return: An iterator like instance of either NotificationCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.NotificationCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -74,40 +197,37 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NotificationCollection', pipeline_response) + deserialized = self._deserialize("NotificationCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,25 +240,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - notification_name, # type: Union[str, "_models.NotificationName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.NotificationContract" + resource_group_name: str, + service_name: str, + notification_name: Union[str, "_models.NotificationName"], + **kwargs: Any + ) -> "_models.NotificationContract": """Gets the details of the Notification specified by its identifier. :param resource_group_name: The name of the resource group. @@ -157,34 +278,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NotificationContract', pipeline_response) @@ -193,17 +304,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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, # type: str - service_name, # type: str - notification_name, # type: Union[str, "_models.NotificationName"] - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.NotificationContract" + resource_group_name: str, + service_name: str, + notification_name: Union[str, "_models.NotificationName"], + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.NotificationContract": """Create or Update API Management publisher notification. :param resource_group_name: The name of the resource group. @@ -225,36 +338,25 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NotificationContract', pipeline_response) @@ -263,4 +365,6 @@ def create_or_update( 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 + 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 931b6c8c565d5..6061a5a94fd0d 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 @@ -5,22 +5,178 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_check_entity_exists_request( + resource_group_name: str, + service_name: str, + notification_name: Union[str, "_models.NotificationName"], + email: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + notification_name: Union[str, "_models.NotificationName"], + email: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + notification_name: Union[str, "_models.NotificationName"], + email: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -44,14 +200,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_notification( self, - resource_group_name, # type: str - service_name, # type: str - notification_name, # type: Union[str, "_models.NotificationName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.RecipientEmailCollection" + resource_group_name: str, + service_name: str, + notification_name: Union[str, "_models.NotificationName"], + **kwargs: Any + ) -> "_models.RecipientEmailCollection": """Gets the list of the Notification Recipient Emails subscribed to a notification. :param resource_group_name: The name of the resource group. @@ -70,34 +226,24 @@ def list_by_notification( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_notification.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RecipientEmailCollection', pipeline_response) @@ -106,17 +252,19 @@ def list_by_notification( 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 + + @distributed_trace def check_entity_exists( self, - resource_group_name, # type: str - service_name, # type: str - notification_name, # type: Union[str, "_models.NotificationName"] - email, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + resource_group_name: str, + service_name: str, + notification_name: Union[str, "_models.NotificationName"], + email: str, + **kwargs: Any + ) -> bool: """Determine if Notification Recipient Email subscribed to the notification. :param resource_group_name: The name of the resource group. @@ -137,52 +285,43 @@ def check_entity_exists( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.check_entity_exists.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'email': self._serialize.url("email", email, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - notification_name, # type: Union[str, "_models.NotificationName"] - email, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RecipientEmailContract" + resource_group_name: str, + service_name: str, + notification_name: Union[str, "_models.NotificationName"], + email: str, + **kwargs: Any + ) -> "_models.RecipientEmailContract": """Adds the Email address to the list of Recipients for the Notification. :param resource_group_name: The name of the resource group. @@ -203,35 +342,25 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'email': self._serialize.url("email", email, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -244,17 +373,19 @@ def create_or_update( 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - notification_name, # type: Union[str, "_models.NotificationName"] - email, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + notification_name: Union[str, "_models.NotificationName"], + email: str, + **kwargs: Any + ) -> None: """Removes the email from the list of Notification. :param resource_group_name: The name of the resource group. @@ -275,38 +406,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'email': self._serialize.url("email", email, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 3208e12b63c33..8f78e5fc84953 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 @@ -5,22 +5,178 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_check_entity_exists_request( + resource_group_name: str, + service_name: str, + notification_name: Union[str, "_models.NotificationName"], + user_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + notification_name: Union[str, "_models.NotificationName"], + user_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + notification_name: Union[str, "_models.NotificationName"], + user_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -44,14 +200,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_notification( self, - resource_group_name, # type: str - service_name, # type: str - notification_name, # type: Union[str, "_models.NotificationName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.RecipientUserCollection" + resource_group_name: str, + service_name: str, + notification_name: Union[str, "_models.NotificationName"], + **kwargs: Any + ) -> "_models.RecipientUserCollection": """Gets the list of the Notification Recipient User subscribed to the notification. :param resource_group_name: The name of the resource group. @@ -70,34 +226,24 @@ def list_by_notification( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_notification.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RecipientUserCollection', pipeline_response) @@ -106,17 +252,19 @@ def list_by_notification( 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 + + @distributed_trace def check_entity_exists( self, - resource_group_name, # type: str - service_name, # type: str - notification_name, # type: Union[str, "_models.NotificationName"] - user_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + resource_group_name: str, + service_name: str, + notification_name: Union[str, "_models.NotificationName"], + user_id: str, + **kwargs: Any + ) -> bool: """Determine if the Notification Recipient User is subscribed to the notification. :param resource_group_name: The name of the resource group. @@ -137,52 +285,43 @@ def check_entity_exists( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.check_entity_exists.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - notification_name, # type: Union[str, "_models.NotificationName"] - user_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RecipientUserContract" + resource_group_name: str, + service_name: str, + notification_name: Union[str, "_models.NotificationName"], + user_id: str, + **kwargs: Any + ) -> "_models.RecipientUserContract": """Adds the API Management User to the list of Recipients for the Notification. :param resource_group_name: The name of the resource group. @@ -203,35 +342,25 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -244,17 +373,19 @@ def create_or_update( 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - notification_name, # type: Union[str, "_models.NotificationName"] - user_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + notification_name: Union[str, "_models.NotificationName"], + user_id: str, + **kwargs: Any + ) -> None: """Removes the API Management user from the list of Notification. :param resource_group_name: The name of the resource group. @@ -275,38 +406,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("notification_name", notification_name, 'str'), - 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 e009f6156a031..0484dacc2721c 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 @@ -5,23 +5,319 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + opid: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + opid: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + opid: 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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 + ) + + +def build_list_secrets_request( + resource_group_name: str, + service_name: str, + opid: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}/listSecrets') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,16 +341,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OpenIdConnectProviderCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.OpenIdConnectProviderCollection"]: """Lists of all the OpenId Connect Providers. :param resource_group_name: The name of the resource group. @@ -72,8 +368,10 @@ def list_by_service( :param skip: Number of records to skip. :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 cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.OpenIdConnectProviderCollection] + :return: An iterator like instance of either OpenIdConnectProviderCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.OpenIdConnectProviderCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenIdConnectProviderCollection"] @@ -81,42 +379,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OpenIdConnectProviderCollection', pipeline_response) + deserialized = self._deserialize("OpenIdConnectProviderCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -129,25 +424,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - opid, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -166,53 +462,45 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - opid, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.OpenidConnectProviderContract" + 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. @@ -231,56 +519,49 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - opid, # type: str - parameters, # type: "_models.OpenidConnectProviderContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.OpenidConnectProviderContract" + resource_group_name: str, + service_name: str, + opid: str, + parameters: "_models.OpenidConnectProviderContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.OpenidConnectProviderContract": """Creates or updates the OpenID Connect Provider. :param resource_group_name: The name of the resource group. @@ -304,68 +585,61 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'OpenidConnectProviderContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'OpenidConnectProviderContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + opid=opid, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - opid, # type: str - if_match, # type: str - parameters, # type: "_models.OpenidConnectProviderUpdateContract" - **kwargs # type: Any - ): - # type: (...) -> "_models.OpenidConnectProviderContract" + resource_group_name: str, + service_name: str, + opid: str, + if_match: str, + parameters: "_models.OpenidConnectProviderUpdateContract", + **kwargs: Any + ) -> "_models.OpenidConnectProviderContract": """Updates the specific OpenID Connect Provider. :param resource_group_name: The name of the resource group. @@ -389,61 +663,54 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'OpenidConnectProviderUpdateContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - opid, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -465,35 +732,25 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -501,14 +758,15 @@ def delete( 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, # type: str - service_name, # type: str - opid, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ClientSecretContract" + 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. @@ -527,42 +785,35 @@ def list_secrets( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_secrets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ClientSecretContract', pipeline_response) 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 + 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 b8405bb50ad5b..ee86fc9538ddd 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 @@ -5,23 +5,75 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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, + api_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + include_not_tagged_operations: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + 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}/operationsByTags') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$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') + + # 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. @@ -45,18 +97,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_tags( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - include_not_tagged_operations=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TagResourceCollection"] + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + include_not_tagged_operations: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.TagResourceCollection"]: """Lists a collection of operations associated with tags. :param resource_group_name: The name of the resource group. @@ -83,7 +135,8 @@ def list_by_tags( :param include_not_tagged_operations: Include not tagged Operations. :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 TagResourceCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -92,45 +145,43 @@ def list_by_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if include_not_tagged_operations is not None: - query_parameters['includeNotTaggedOperations'] = self._serialize.query("include_not_tagged_operations", include_not_tagged_operations, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagResourceCollection', pipeline_response) + deserialized = self._deserialize("TagResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -143,12 +194,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_outbound_network_dependencies_endpoints_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_outbound_network_dependencies_endpoints_operations.py new file mode 100644 index 0000000000000..74a87898f7fbb --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_outbound_network_dependencies_endpoints_operations.py @@ -0,0 +1,134 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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.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') +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 +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/outboundNetworkDependenciesEndpoints') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', 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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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: ~azure.mgmt.apimanagement.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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + **kwargs: Any + ) -> "_models.OutboundEnvironmentEndpointList": + """Gets the network endpoints of all outbound dependencies of a ApiManagement service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :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: ~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 + } + error_map.update(kwargs.pop('error_map', {})) + + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('OutboundEnvironmentEndpointList', pipeline_response) + + 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 + 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 e86c4a31fb351..09469fcc97cc3 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 @@ -5,22 +5,63 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyDescriptions') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # 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') + + # 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. @@ -44,14 +85,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - scope=None, # type: Optional[Union[str, "_models.PolicyScopeContract"]] - **kwargs # type: Any - ): - # type: (...) -> "_models.PolicyDescriptionCollection" + resource_group_name: str, + service_name: str, + scope: Optional[Union[str, "_models.PolicyScopeContract"]] = None, + **kwargs: Any + ) -> "_models.PolicyDescriptionCollection": """Lists all policy descriptions. :param resource_group_name: The name of the resource group. @@ -70,35 +111,24 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if scope is not None: - query_parameters['scope'] = self._serialize.query("scope", scope, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyDescriptionCollection', pipeline_response) @@ -107,4 +137,6 @@ def list_by_service( return cls(pipeline_response, deserialized, {}) return deserialized + 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 c529d0c960de1..11919ca3c9be1 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 @@ -5,22 +5,227 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + policy_id: Union[str, "_models.PolicyIdName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + policy_id: Union[str, "_models.PolicyIdName"], + subscription_id: str, + *, + format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # 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') + + # 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_create_or_update_request( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + policy_id: Union[str, "_models.PolicyIdName"], + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -44,13 +249,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PolicyCollection" + 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. @@ -67,33 +272,23 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyCollection', pipeline_response) @@ -102,16 +297,18 @@ def list_by_service( return cls(pipeline_response, deserialized, {}) return deserialized + 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, # type: str - service_name, # type: str - policy_id, # type: Union[str, "_models.PolicyIdName"] - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -131,54 +328,46 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - policy_id, # type: Union[str, "_models.PolicyIdName"] - format="xml", # type: Optional[Union[str, "_models.PolicyExportFormat"]] - **kwargs # type: Any - ): - # type: (...) -> "_models.PolicyContract" + resource_group_name: str, + service_name: str, + policy_id: Union[str, "_models.PolicyIdName"], + format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", + **kwargs: Any + ) -> "_models.PolicyContract": """Get the Global policy definition of the Api Management service. :param resource_group_name: The name of the resource group. @@ -199,58 +388,50 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if format is not None: - query_parameters['format'] = self._serialize.query("format", format, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - policy_id, # type: Union[str, "_models.PolicyIdName"] - parameters, # type: "_models.PolicyContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.PolicyContract" + resource_group_name: str, + service_name: str, + policy_id: Union[str, "_models.PolicyIdName"], + parameters: "_models.PolicyContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.PolicyContract": """Creates or updates the global policy configuration of the Api Management service. :param resource_group_name: The name of the resource group. @@ -274,67 +455,60 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - policy_id, # type: Union[str, "_models.PolicyIdName"] - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + policy_id: Union[str, "_models.PolicyIdName"], + if_match: str, + **kwargs: Any + ) -> None: """Deletes the global policy configuration of the Api Management Service. :param resource_group_name: The name of the resource group. @@ -356,38 +530,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 9a39ef3889ff1..1f635b42fd5a0 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 @@ -5,25 +5,241 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + portal_revision_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_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 +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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. @@ -47,16 +263,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PortalRevisionCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.PortalRevisionCollection"]: """Lists developer portal's revisions. :param resource_group_name: The name of the resource group. @@ -81,7 +297,8 @@ def list_by_service( :param skip: Number of records to skip. :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 cls(response) + :return: An iterator like instance of either PortalRevisionCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PortalRevisionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -90,42 +307,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PortalRevisionCollection', pipeline_response) + deserialized = self._deserialize("PortalRevisionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -138,25 +352,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - portal_revision_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -176,53 +391,45 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("portal_revision_id", portal_revision_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - portal_revision_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PortalRevisionContract" + 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. @@ -242,116 +449,100 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("portal_revision_id", portal_revision_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PortalRevisionContract', pipeline_response) 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 + def _create_or_update_initial( self, - resource_group_name, # type: str - service_name, # type: str - portal_revision_id, # type: str - parameters, # type: "_models.PortalRevisionContract" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.PortalRevisionContract"] + resource_group_name: str, + service_name: str, + portal_revision_id: str, + parameters: "_models.PortalRevisionContract", + **kwargs: Any + ) -> Optional["_models.PortalRevisionContract"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PortalRevisionContract"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("portal_revision_id", portal_revision_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PortalRevisionContract') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + 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, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PortalRevisionContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} 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) 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 + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - portal_revision_id, # type: str - parameters, # type: "_models.PortalRevisionContract" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PortalRevisionContract"] + resource_group_name: str, + service_name: str, + portal_revision_id: str, + parameters: "_models.PortalRevisionContract", + **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. @@ -366,15 +557,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract :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. + :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) + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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', @@ -387,31 +582,24 @@ def begin_create_or_update( service_name=service_name, portal_revision_id=portal_revision_id, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', 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) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("portal_revision_id", portal_revision_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -423,81 +611,73 @@ def get_long_running_output(pipeline_response): ) else: 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 def _update_initial( self, - resource_group_name, # type: str - service_name, # type: str - portal_revision_id, # type: str - if_match, # type: str - parameters, # type: "_models.PortalRevisionContract" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.PortalRevisionContract"] + resource_group_name: str, + service_name: str, + portal_revision_id: str, + if_match: str, + parameters: "_models.PortalRevisionContract", + **kwargs: Any + ) -> Optional["_models.PortalRevisionContract"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PortalRevisionContract"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("portal_revision_id", portal_revision_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PortalRevisionContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PortalRevisionContract') + + request = build_update_request_initial( + 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, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PortalRevisionContract', pipeline_response) if 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 + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - service_name, # type: str - portal_revision_id, # type: str - if_match, # type: str - parameters, # type: "_models.PortalRevisionContract" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PortalRevisionContract"] + resource_group_name: str, + service_name: str, + portal_revision_id: str, + if_match: str, + parameters: "_models.PortalRevisionContract", + **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. @@ -514,15 +694,19 @@ def begin_update( :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract :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. + :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) + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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', @@ -536,31 +720,24 @@ def begin_update( portal_revision_id=portal_revision_id, if_match=if_match, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', 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) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("portal_revision_id", portal_revision_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -572,4 +749,5 @@ def get_long_running_output(pipeline_response): ) else: 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 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 7e600fee175ed..890d34926b4a5 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 @@ -5,22 +5,59 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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 +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -44,13 +81,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PortalSettingsCollection" + 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. @@ -67,33 +104,23 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PortalSettingsCollection', pipeline_response) @@ -102,4 +129,6 @@ def list_by_service( return cls(pipeline_response, deserialized, {}) return deserialized + 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 new file mode 100644 index 0000000000000..e93d43e3faf36 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_private_endpoint_connection_operations.py @@ -0,0 +1,746 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 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.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 +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 +) -> HttpRequest: + 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') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_get_by_name_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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request_initial( + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_delete_request_initial( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_private_link_resources_request( + resource_group_name: str, + subscription_id: str, + service_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources') + 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])?$'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_get_private_link_resource_request( + resource_group_name: str, + subscription_id: str, + service_name: str, + private_link_sub_resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources/{privateLinkSubResourceName}') + 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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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: ~azure.mgmt.apimanagement.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. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + """Lists all private endpoint connections of the API Management service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :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) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PrivateEndpointConnectionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + 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": + """Gets the details of the Private Endpoint Connection specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param private_endpoint_connection_name: Name of the private endpoint connection. + :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: ~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 + } + error_map.update(kwargs.pop('error_map', {})) + + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + + 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 + + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection_request: "_models.PrivateEndpointConnectionRequest", + **kwargs: Any + ) -> Optional["_models.PrivateEndpointConnection"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(private_endpoint_connection_request, 'PrivateEndpointConnectionRequest') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + 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 + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection_request: "_models.PrivateEndpointConnectionRequest", + **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. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param private_endpoint_connection_name: Name of the private endpoint connection. + :type private_endpoint_connection_name: str + :param private_endpoint_connection_request: + :type private_endpoint_connection_request: + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequest + :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 + """ + 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] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection_request=private_endpoint_connection_request, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_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 cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + 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 + + def _delete_initial( + 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 + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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) + + if cls: + return cls(pipeline_response, None, {}) + + _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 + ) -> LROPoller[None]: + """Deletes the specified Private Endpoint Connection. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param private_endpoint_connection_name: Name of the private endpoint connection. + :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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :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] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + service_name=service_name, + private_endpoint_connection_name=private_endpoint_connection_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + 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 cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + 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 + + @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. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :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: ~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 + } + error_map.update(kwargs.pop('error_map', {})) + + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + + 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 + + + @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. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param private_link_sub_resource_name: Name of the private link resource. + :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: ~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 + } + error_map.update(kwargs.pop('error_map', {})) + + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateLinkResource', pipeline_response) + + 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 + 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 c90bccc74527a..072ff227c70d2 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 @@ -5,23 +5,189 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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}/apis') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_check_entity_exists_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,17 +211,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_product( self, - resource_group_name, # type: str - service_name, # type: str - product_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApiCollection"] + resource_group_name: str, + service_name: str, + product_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ApiCollection"]: """Lists a collection of the APIs associated with a product. :param resource_group_name: The name of the resource group. @@ -88,43 +254,41 @@ def list_by_product( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_product.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_product.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ApiCollection', pipeline_response) + deserialized = self._deserialize("ApiCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -137,26 +301,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - product_id, # type: str - api_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -179,52 +344,43 @@ def check_entity_exists( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.check_entity_exists.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - product_id, # type: str - api_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApiContract" + 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. @@ -247,35 +403,25 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -288,17 +434,19 @@ def create_or_update( 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - product_id, # type: str - api_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -321,38 +469,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 9889fcdfd5502..3f21073ba7233 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 @@ -5,23 +5,189 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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}/groups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_check_entity_exists_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,17 +211,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_product( self, - resource_group_name, # type: str - service_name, # type: str - product_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GroupCollection"] + resource_group_name: str, + service_name: str, + product_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.GroupCollection"]: """Lists the collection of developer groups associated with the specified product. :param resource_group_name: The name of the resource group. @@ -84,43 +250,41 @@ def list_by_product( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_product.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_product.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('GroupCollection', pipeline_response) + deserialized = self._deserialize("GroupCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -133,26 +297,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - product_id, # type: str - group_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -175,52 +340,43 @@ def check_entity_exists( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.check_entity_exists.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - product_id, # type: str - group_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GroupContract" + 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. @@ -243,35 +399,25 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -284,17 +430,19 @@ def create_or_update( 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - product_id, # type: str - group_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -317,38 +465,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 a6851c0ce8979..9cfa3ef800262 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 @@ -5,23 +5,339 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + expand_groups: Optional[bool] = None, + tags: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + if expand_groups is not None: + query_parameters['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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + product_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + product_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + product_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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + product_id: str, + subscription_id: str, + *, + if_match: str, + delete_subscriptions: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # 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') + + # 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 + ) + + +def build_list_by_tags_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + include_not_tagged_products: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/productsByTags') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$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') + + # 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. @@ -45,18 +361,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - expand_groups=None, # type: Optional[bool] - tags=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + expand_groups: Optional[bool] = None, + tags: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ProductCollection"]: """Lists a collection of products in the specified service instance. :param resource_group_name: The name of the resource group. @@ -90,46 +406,43 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if expand_groups is not None: - query_parameters['expandGroups'] = self._serialize.query("expand_groups", expand_groups, 'bool') - if tags is not None: - query_parameters['tags'] = self._serialize.query("tags", tags, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ProductCollection', pipeline_response) + deserialized = self._deserialize("ProductCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -142,25 +455,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - product_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -180,53 +494,45 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - product_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ProductContract" + 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. @@ -246,56 +552,49 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ProductContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - product_id, # type: str - parameters, # type: "_models.ProductContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.ProductContract" + resource_group_name: str, + service_name: str, + product_id: str, + parameters: "_models.ProductContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.ProductContract": """Creates or Updates a product. :param resource_group_name: The name of the resource group. @@ -320,68 +619,61 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ProductContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ProductContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - product_id, # type: str - if_match, # type: str - parameters, # type: "_models.ProductUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.ProductContract" + resource_group_name: str, + service_name: str, + product_id: str, + if_match: str, + parameters: "_models.ProductUpdateParameters", + **kwargs: Any + ) -> "_models.ProductContract": """Update existing product details. :param resource_group_name: The name of the resource group. @@ -406,62 +698,55 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ProductUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ProductContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - product_id, # type: str - if_match, # type: str - delete_subscriptions=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + product_id: str, + if_match: str, + delete_subscriptions: Optional[bool] = None, + **kwargs: Any + ) -> None: """Delete product. :param resource_group_name: The name of the resource group. @@ -486,37 +771,26 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if delete_subscriptions is not None: - query_parameters['deleteSubscriptions'] = self._serialize.query("delete_subscriptions", delete_subscriptions, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + delete_subscriptions=delete_subscriptions, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -524,17 +798,18 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + + @distributed_trace def list_by_tags( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - include_not_tagged_products=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TagResourceCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + include_not_tagged_products: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.TagResourceCollection"]: """Lists a collection of products associated with tags. :param resource_group_name: The name of the resource group. @@ -556,7 +831,8 @@ def list_by_tags( :param include_not_tagged_products: Include not tagged Products. :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 TagResourceCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -565,44 +841,41 @@ def list_by_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if include_not_tagged_products is not None: - query_parameters['includeNotTaggedProducts'] = self._serialize.query("include_not_tagged_products", include_not_tagged_products, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagResourceCollection', pipeline_response) + deserialized = self._deserialize("TagResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -615,12 +888,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_policy_operations.py index 119dd54e377a6..fbf3fe98dc359 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 @@ -5,22 +5,237 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_product_request( + resource_group_name: str, + service_name: str, + product_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + product_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + subscription_id: str, + *, + format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # 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') + + # 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_create_or_update_request( + resource_group_name: str, + service_name: str, + product_id: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -44,14 +259,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_product( self, - resource_group_name, # type: str - service_name, # type: str - product_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PolicyCollection" + 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. @@ -71,34 +286,24 @@ def list_by_product( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_product.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyCollection', pipeline_response) @@ -107,17 +312,19 @@ def list_by_product( 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 + + @distributed_trace def get_entity_tag( self, - resource_group_name, # type: str - service_name, # type: str - product_id, # type: str - policy_id, # type: Union[str, "_models.PolicyIdName"] - **kwargs # type: Any - ): - # type: (...) -> bool + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + **kwargs: Any + ) -> bool: """Get the ETag of the policy configuration at the Product level. :param resource_group_name: The name of the resource group. @@ -139,56 +346,48 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace def get( self, - resource_group_name, # type: str - service_name, # type: str - product_id, # type: str - policy_id, # type: Union[str, "_models.PolicyIdName"] - format="xml", # type: Optional[Union[str, "_models.PolicyExportFormat"]] - **kwargs # type: Any - ): - # type: (...) -> "_models.PolicyContract" + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", + **kwargs: Any + ) -> "_models.PolicyContract": """Get the policy configuration at the Product level. :param resource_group_name: The name of the resource group. @@ -212,60 +411,52 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if format is not None: - query_parameters['format'] = self._serialize.query("format", format, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - product_id, # type: str - policy_id, # type: Union[str, "_models.PolicyIdName"] - parameters, # type: "_models.PolicyContract" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.PolicyContract" + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + parameters: "_models.PolicyContract", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.PolicyContract": """Creates or updates policy configuration for the Product. :param resource_group_name: The name of the resource group. @@ -292,69 +483,62 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PolicyContract') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PolicyContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - product_id, # type: str - policy_id, # type: Union[str, "_models.PolicyIdName"] - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, "_models.PolicyIdName"], + if_match: str, + **kwargs: Any + ) -> None: """Deletes the policy configuration at the Product. :param resource_group_name: The name of the resource group. @@ -379,39 +563,30 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'policyId': self._serialize.url("policy_id", policy_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 690183d990648..b7475809ecf7a 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 @@ -5,23 +5,72 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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, + product_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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}/subscriptions') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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. @@ -45,17 +94,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - service_name, # type: str - product_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SubscriptionCollection"] + resource_group_name: str, + service_name: str, + product_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SubscriptionCollection"]: """Lists the collection of subscriptions to the specified product. :param resource_group_name: The name of the resource group. @@ -82,7 +131,8 @@ def list( :param skip: Number of records to skip. :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 cls(response) + :return: An iterator like instance of either SubscriptionCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.SubscriptionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -91,43 +141,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionCollection', pipeline_response) + deserialized = self._deserialize("SubscriptionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -140,12 +188,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_counter_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_counter_keys_operations.py index 82b61a3d6fadd..88c8b552fbc65 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 @@ -5,22 +5,108 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace 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 +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_list_by_service_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_update_request( + resource_group_name: str, + service_name: str, + quota_counter_key: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -44,14 +130,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - quota_counter_key, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.QuotaCounterCollection" + 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. @@ -74,34 +160,24 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("quota_counter_key", quota_counter_key, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('QuotaCounterCollection', pipeline_response) @@ -110,17 +186,19 @@ def list_by_service( 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - quota_counter_key, # type: str - parameters, # type: "_models.QuotaCounterValueUpdateContract" - **kwargs # type: Any - ): - # type: (...) -> "_models.QuotaCounterCollection" + resource_group_name: str, + service_name: str, + quota_counter_key: str, + parameters: "_models.QuotaCounterValueUpdateContract", + **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. @@ -145,39 +223,29 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("quota_counter_key", quota_counter_key, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'QuotaCounterValueUpdateContract') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + 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, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'QuotaCounterValueUpdateContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('QuotaCounterCollection', pipeline_response) @@ -186,4 +254,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + 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 6df627a39af2f..1ec29fd58636f 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 @@ -5,22 +5,112 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace 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 +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_get_request( + resource_group_name: str, + service_name: str, + quota_counter_key: str, + quota_period_key: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_update_request( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -44,15 +134,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - service_name, # type: str - quota_counter_key, # type: str - quota_period_key, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.QuotaCounterContract" + 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. @@ -77,35 +167,25 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("quota_counter_key", quota_counter_key, 'str'), - 'quotaPeriodKey': self._serialize.url("quota_period_key", quota_period_key, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('QuotaCounterContract', pipeline_response) @@ -114,18 +194,20 @@ def get( 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - quota_counter_key, # type: str - quota_period_key, # type: str - parameters, # type: "_models.QuotaCounterValueUpdateContract" - **kwargs # type: Any - ): - # type: (...) -> "_models.QuotaCounterContract" + resource_group_name: str, + service_name: str, + quota_counter_key: str, + quota_period_key: str, + parameters: "_models.QuotaCounterValueUpdateContract", + **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. @@ -151,40 +233,30 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("quota_counter_key", quota_counter_key, 'str'), - 'quotaPeriodKey': self._serialize.url("quota_period_key", quota_period_key, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'QuotaCounterValueUpdateContract') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + quota_counter_key=quota_counter_key, + quota_period_key=quota_period_key, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'QuotaCounterValueUpdateContract') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('QuotaCounterContract', pipeline_response) @@ -193,4 +265,6 @@ def update( 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 + 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 6e71b599621ca..946c0034f77e3 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 @@ -5,23 +5,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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 +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/regions') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,13 +82,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RegionListResult"] + resource_group_name: str, + service_name: str, + **kwargs: Any + ) -> Iterable["_models.RegionListResult"]: """Lists all azure regions in which the service exists. :param resource_group_name: The name of the resource group. @@ -68,36 +105,33 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RegionListResult', pipeline_response) + deserialized = self._deserialize("RegionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,12 +144,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_reports_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_reports_operations.py index 64e0d959dc30b..8b355736f137a 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 @@ -6,23 +6,397 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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, + subscription_id: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$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') + + # 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_list_by_user_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$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') + + # 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_list_by_operation_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$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') + + # 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_list_by_product_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$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') + + # 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_list_by_geo_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_list_by_subscription_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$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') + + # 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_list_by_time_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: str, + interval: datetime.timedelta, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$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') + + # 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_list_by_request_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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. @@ -46,17 +420,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_api( self, - resource_group_name, # type: str - service_name, # type: str - filter, # type: str - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ReportCollection"] + resource_group_name: str, + service_name: str, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ReportCollection"]: """Lists report records by API. :param resource_group_name: The name of the resource group. @@ -81,43 +455,41 @@ def list_by_api( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_api.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_api.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ReportCollection', pipeline_response) + deserialized = self._deserialize("ReportCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -130,28 +502,29 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi'} # type: ignore + @distributed_trace def list_by_user( self, - resource_group_name, # type: str - service_name, # type: str - filter, # type: str - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ReportCollection"] + resource_group_name: str, + service_name: str, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ReportCollection"]: """Lists report records by User. :param resource_group_name: The name of the resource group. @@ -188,43 +561,41 @@ def list_by_user( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_user.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_user.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ReportCollection', pipeline_response) + deserialized = self._deserialize("ReportCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -237,28 +608,29 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_user.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser'} # type: ignore + @distributed_trace def list_by_operation( self, - resource_group_name, # type: str - service_name, # type: str - filter, # type: str - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ReportCollection"] + resource_group_name: str, + service_name: str, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ReportCollection"]: """Lists report records by API Operations. :param resource_group_name: The name of the resource group. @@ -295,43 +667,41 @@ def list_by_operation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_operation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_operation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ReportCollection', pipeline_response) + deserialized = self._deserialize("ReportCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -344,28 +714,29 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation'} # type: ignore + @distributed_trace def list_by_product( self, - resource_group_name, # type: str - service_name, # type: str - filter, # type: str - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ReportCollection"] + resource_group_name: str, + service_name: str, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ReportCollection"]: """Lists report records by Product. :param resource_group_name: The name of the resource group. @@ -401,43 +772,41 @@ def list_by_product( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_product.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_product.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ReportCollection', pipeline_response) + deserialized = self._deserialize("ReportCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -450,27 +819,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct'} # type: ignore + @distributed_trace def list_by_geo( self, - resource_group_name, # type: str - service_name, # type: str - filter, # type: str - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ReportCollection"] + resource_group_name: str, + service_name: str, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.ReportCollection"]: """Lists report records by geography. :param resource_group_name: The name of the resource group. @@ -505,41 +875,39 @@ def list_by_geo( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_geo.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_geo.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ReportCollection', pipeline_response) + deserialized = self._deserialize("ReportCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -552,28 +920,29 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_geo.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo'} # type: ignore + @distributed_trace def list_by_subscription( self, - resource_group_name, # type: str - service_name, # type: str - filter, # type: str - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ReportCollection"] + resource_group_name: str, + service_name: str, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ReportCollection"]: """Lists report records by subscription. :param resource_group_name: The name of the resource group. @@ -609,43 +978,41 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ReportCollection', pipeline_response) + deserialized = self._deserialize("ReportCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -658,29 +1025,30 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription'} # type: ignore + @distributed_trace def list_by_time( self, - resource_group_name, # type: str - service_name, # type: str - filter, # type: str - interval, # type: datetime.timedelta - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - orderby=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ReportCollection"] + resource_group_name: str, + service_name: str, + filter: str, + interval: datetime.timedelta, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ReportCollection"]: """Lists report records by Time. :param resource_group_name: The name of the resource group. @@ -721,44 +1089,43 @@ def list_by_time( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_time.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['interval'] = self._serialize.query("interval", interval, 'duration') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_time.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ReportCollection', pipeline_response) + deserialized = self._deserialize("ReportCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -771,27 +1138,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_time.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime'} # type: ignore + @distributed_trace def list_by_request( self, - resource_group_name, # type: str - service_name, # type: str - filter, # type: str - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RequestReportCollection"] + resource_group_name: str, + service_name: str, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.RequestReportCollection"]: """Lists report records by Request. :param resource_group_name: The name of the resource group. @@ -809,7 +1177,8 @@ def list_by_request( :param skip: Number of records to skip. :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 cls(response) + :return: An iterator like instance of either RequestReportCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.RequestReportCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -818,41 +1187,39 @@ def list_by_request( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_request.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_request.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RequestReportCollection', pipeline_response) + deserialized = self._deserialize("RequestReportCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -865,12 +1232,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_in_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_in_settings_operations.py index e328cdc7bc893..cef8532cfb0aa 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 @@ -5,22 +5,188 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_entity_tag_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_update_request( + resource_group_name: str, + service_name: 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] + + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_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 +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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. @@ -44,13 +210,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_entity_tag( self, - resource_group_name, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -67,51 +233,43 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PortalSigninSettings" + 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. @@ -128,54 +286,47 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PortalSigninSettings', pipeline_response) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - if_match, # type: str - parameters, # type: "_models.PortalSigninSettings" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + if_match: str, + parameters: "_models.PortalSigninSettings", + **kwargs: Any + ) -> None: """Update Sign-In settings. :param resource_group_name: The name of the resource group. @@ -197,39 +348,29 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PortalSigninSettings') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PortalSigninSettings') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -237,15 +378,16 @@ def update( update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - parameters, # type: "_models.PortalSigninSettings" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.PortalSigninSettings" + resource_group_name: str, + service_name: str, + parameters: "_models.PortalSigninSettings", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.PortalSigninSettings": """Create or Update Sign-In settings. :param resource_group_name: The name of the resource group. @@ -267,40 +409,29 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PortalSigninSettings') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PortalSigninSettings') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PortalSigninSettings', pipeline_response) @@ -309,4 +440,6 @@ def create_or_update( 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 + 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 5190b4fd34866..94818dd6c8937 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 @@ -5,22 +5,188 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_entity_tag_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_update_request( + resource_group_name: str, + service_name: 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] + + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_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 +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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. @@ -44,13 +210,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_entity_tag( self, - resource_group_name, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -67,51 +233,43 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PortalSignupSettings" + 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. @@ -128,54 +286,47 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PortalSignupSettings', pipeline_response) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - if_match, # type: str - parameters, # type: "_models.PortalSignupSettings" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + if_match: str, + parameters: "_models.PortalSignupSettings", + **kwargs: Any + ) -> None: """Update Sign-Up settings. :param resource_group_name: The name of the resource group. @@ -197,39 +348,29 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PortalSignupSettings') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PortalSignupSettings') + + request = build_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -237,15 +378,16 @@ def update( update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - parameters, # type: "_models.PortalSignupSettings" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.PortalSignupSettings" + resource_group_name: str, + service_name: str, + parameters: "_models.PortalSignupSettings", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.PortalSignupSettings": """Create or Update Sign-Up settings. :param resource_group_name: The name of the resource group. @@ -267,40 +409,29 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PortalSignupSettings') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PortalSignupSettings') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PortalSignupSettings', pipeline_response) @@ -309,4 +440,6 @@ def create_or_update( 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 + 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 3a67964398912..734b407d3135c 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 @@ -5,23 +5,405 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + sid: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + sid: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + 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, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + 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') + if app_type is not None: + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + sid: str, + subscription_id: str, + *, + if_match: str, + json: JSONType = None, + content: Any = None, + notify: Optional[bool] = None, + app_type: Optional[Union[str, "_models.AppType"]] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + 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') + if app_type is not None: + query_parameters['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') + 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_delete_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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 + ) + + +def build_regenerate_primary_key_request( + resource_group_name: str, + service_name: str, + sid: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}/regeneratePrimaryKey') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_regenerate_secondary_key_request( + resource_group_name: str, + service_name: str, + sid: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}/regenerateSecondaryKey') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_list_secrets_request( + resource_group_name: str, + service_name: str, + sid: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}/listSecrets') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,16 +427,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SubscriptionCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SubscriptionCollection"]: """Lists all subscriptions of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -78,7 +460,8 @@ def list( :param skip: Number of records to skip. :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 cls(response) + :return: An iterator like instance of either SubscriptionCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.SubscriptionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -87,42 +470,39 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionCollection', pipeline_response) + deserialized = self._deserialize("SubscriptionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -135,25 +515,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - sid, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -174,53 +555,45 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - sid, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SubscriptionContract" + 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. @@ -240,58 +613,51 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SubscriptionContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - sid, # type: str - parameters, # type: "_models.SubscriptionCreateParameters" - notify=None, # type: Optional[bool] - if_match=None, # type: Optional[str] - app_type=None, # type: Optional[Union[str, "_models.AppType"]] - **kwargs # type: Any - ): - # type: (...) -> "_models.SubscriptionContract" + 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, + **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. @@ -325,74 +691,65 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if notify is not None: - query_parameters['notify'] = self._serialize.query("notify", notify, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if app_type is not None: - query_parameters['appType'] = self._serialize.query("app_type", app_type, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SubscriptionCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - sid, # type: str - if_match, # type: str - parameters, # type: "_models.SubscriptionUpdateParameters" - notify=None, # type: Optional[bool] - app_type=None, # type: Optional[Union[str, "_models.AppType"]] - **kwargs # type: Any - ): - # type: (...) -> "_models.SubscriptionContract" + 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, + **kwargs: Any + ) -> "_models.SubscriptionContract": """Updates the details of a subscription specified by its identifier. :param resource_group_name: The name of the resource group. @@ -426,65 +783,56 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if notify is not None: - query_parameters['notify'] = self._serialize.query("notify", notify, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if app_type is not None: - query_parameters['appType'] = self._serialize.query("app_type", app_type, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SubscriptionUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SubscriptionContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - sid, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -507,35 +855,25 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -543,14 +881,15 @@ def delete( 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, # type: str - service_name, # type: str - sid, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -570,34 +909,24 @@ def regenerate_primary_key( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.regenerate_primary_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -605,14 +934,15 @@ def regenerate_primary_key( 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, # type: str - service_name, # type: str - sid, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -632,34 +962,24 @@ def regenerate_secondary_key( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.regenerate_secondary_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -667,14 +987,15 @@ def regenerate_secondary_key( 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, # type: str - service_name, # type: str - sid, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SubscriptionKeysContract" + 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. @@ -694,42 +1015,35 @@ def list_secrets( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_secrets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SubscriptionKeysContract', pipeline_response) 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 + 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 dc4a6e8f260b0..862ffc83ab624 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 @@ -5,23 +5,904 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_operation_request( + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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}/tags') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_state_by_operation_request( + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + tag_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}/tags/{tagId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_by_operation_request( + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + tag_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}/tags/{tagId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_assign_to_operation_request( + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + tag_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}/tags/{tagId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_detach_from_operation_request( + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + tag_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}/tags/{tagId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_api_request( + resource_group_name: str, + service_name: str, + api_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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}/tags') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_state_by_api_request( + resource_group_name: str, + service_name: str, + api_id: str, + tag_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}/tags/{tagId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_by_api_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_assign_to_api_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_detach_from_api_request( + resource_group_name: str, + service_name: str, + api_id: str, + tag_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}/tags/{tagId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_product_request( + resource_group_name: str, + service_name: str, + product_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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}/tags') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_entity_state_by_product_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_by_product_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_assign_to_product_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_detach_from_product_request( + resource_group_name: str, + service_name: str, + product_id: str, + tag_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}/tags/{tagId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + scope: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$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') + + # 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_get_entity_state_request( + resource_group_name: str, + service_name: str, + tag_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + tag_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + tag_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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,18 +926,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_operation( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - operation_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TagCollection"] + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.TagCollection"]: """Lists all Tags associated with the Operation. :param resource_group_name: The name of the resource group. @@ -88,44 +969,43 @@ def list_by_operation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_operation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_operation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagCollection', pipeline_response) + deserialized = self._deserialize("TagCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -138,27 +1018,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - api_id, # type: str - operation_id, # type: str - tag_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -183,57 +1064,49 @@ def get_entity_state_by_operation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_state_by_operation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_entity_state_by_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + template_url=self.get_entity_state_by_operation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace def get_by_operation( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - operation_id, # type: str - tag_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.TagContract" + 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. @@ -258,58 +1131,51 @@ def get_by_operation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_by_operation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + template_url=self.get_by_operation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) 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 + + @distributed_trace def assign_to_operation( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - operation_id, # type: str - tag_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.TagContract" + 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. @@ -334,36 +1200,26 @@ def assign_to_operation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.assign_to_operation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_assign_to_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + template_url=self.assign_to_operation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -376,18 +1232,20 @@ def assign_to_operation( 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 + + @distributed_trace def detach_from_operation( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - operation_id, # type: str - tag_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -412,36 +1270,26 @@ def detach_from_operation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.detach_from_operation.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_detach_from_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + template_url=self.detach_from_operation.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -449,17 +1297,18 @@ def detach_from_operation( 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( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TagCollection"] + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.TagCollection"]: """Lists all Tags associated with the API. :param resource_group_name: The name of the resource group. @@ -488,43 +1337,41 @@ def list_by_api( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_api.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_api.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagCollection', pipeline_response) + deserialized = self._deserialize("TagCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -537,26 +1384,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - api_id, # type: str - tag_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -578,55 +1426,47 @@ def get_entity_state_by_api( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_state_by_api.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace def get_by_api( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - tag_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.TagContract" + 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. @@ -648,56 +1488,49 @@ def get_by_api( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_by_api.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) 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 + + @distributed_trace def assign_to_api( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - tag_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.TagContract" + 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. @@ -719,61 +1552,55 @@ def assign_to_api( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.assign_to_api.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def detach_from_api( self, - resource_group_name, # type: str - service_name, # type: str - api_id, # type: str - tag_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -795,35 +1622,25 @@ def detach_from_api( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.detach_from_api.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -831,17 +1648,18 @@ def detach_from_api( 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( self, - resource_group_name, # type: str - service_name, # type: str - product_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TagCollection"] + resource_group_name: str, + service_name: str, + product_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.TagCollection"]: """Lists all Tags associated with the Product. :param resource_group_name: The name of the resource group. @@ -870,43 +1688,41 @@ def list_by_product( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_product.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_product.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagCollection', pipeline_response) + deserialized = self._deserialize("TagCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -919,26 +1735,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - product_id, # type: str - tag_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -960,55 +1777,47 @@ def get_entity_state_by_product( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_state_by_product.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - 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 + + @distributed_trace def get_by_product( self, - resource_group_name, # type: str - service_name, # type: str - product_id, # type: str - tag_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.TagContract" + 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. @@ -1030,56 +1839,49 @@ def get_by_product( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_by_product.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) 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 + + @distributed_trace def assign_to_product( self, - resource_group_name, # type: str - service_name, # type: str - product_id, # type: str - tag_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.TagContract" + 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. @@ -1101,35 +1903,25 @@ def assign_to_product( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.assign_to_product.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -1142,17 +1934,19 @@ def assign_to_product( 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 + + @distributed_trace def detach_from_product( self, - resource_group_name, # type: str - service_name, # type: str - product_id, # type: str - tag_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -1174,35 +1968,25 @@ def detach_from_product( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.detach_from_product.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1210,17 +1994,18 @@ def detach_from_product( 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( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - scope=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TagCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + scope: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.TagCollection"]: """Lists a collection of tags defined within a service instance. :param resource_group_name: The name of the resource group. @@ -1249,44 +2034,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if scope is not None: - query_parameters['scope'] = self._serialize.query("scope", scope, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagCollection', pipeline_response) + deserialized = self._deserialize("TagCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1299,25 +2081,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - tag_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -1336,53 +2119,45 @@ def get_entity_state( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_state.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - tag_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.TagContract" + 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. @@ -1401,56 +2176,49 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - tag_id, # type: str - parameters, # type: "_models.TagCreateUpdateParameters" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.TagContract" + resource_group_name: str, + service_name: str, + tag_id: str, + parameters: "_models.TagCreateUpdateParameters", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.TagContract": """Creates a tag. :param resource_group_name: The name of the resource group. @@ -1474,68 +2242,61 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - tag_id, # type: str - if_match, # type: str - parameters, # type: "_models.TagCreateUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.TagContract" + resource_group_name: str, + service_name: str, + tag_id: str, + if_match: str, + parameters: "_models.TagCreateUpdateParameters", + **kwargs: Any + ) -> "_models.TagContract": """Updates the details of the tag specified by its identifier. :param resource_group_name: The name of the resource group. @@ -1559,61 +2320,54 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TagCreateUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - tag_id, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -1635,38 +2389,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = 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.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 2d0701f386ab2..a47945da9c866 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 @@ -5,23 +5,70 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tagResources') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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. @@ -45,16 +92,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TagResourceCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.TagResourceCollection"]: """Lists a collection of resources associated with tags. :param resource_group_name: The name of the resource group. @@ -82,7 +129,8 @@ def list_by_service( :param skip: Number of records to skip. :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 TagResourceCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -91,42 +139,39 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TagResourceCollection', pipeline_response) + deserialized = self._deserialize("TagResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -139,12 +184,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_git_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_git_operations.py index 34fb3ef48c9f1..ff3f02114c0b7 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 @@ -5,22 +5,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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, + subscription_id: str, + access_name: Union[str, "_models.AccessIdName"], + **kwargs: Any +) -> HttpRequest: + 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}/git/regeneratePrimaryKey') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_regenerate_secondary_key_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + access_name: Union[str, "_models.AccessIdName"], + **kwargs: Any +) -> HttpRequest: + 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}/git/regenerateSecondaryKey') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -44,14 +120,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def regenerate_primary_key( self, - resource_group_name, # type: str - service_name, # type: str - access_name, # type: Union[str, "_models.AccessIdName"] - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -70,34 +146,24 @@ def regenerate_primary_key( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.regenerate_primary_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'accessName': self._serialize.url("access_name", access_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -105,14 +171,15 @@ def regenerate_primary_key( 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, # type: str - service_name, # type: str - access_name, # type: Union[str, "_models.AccessIdName"] - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -131,37 +198,28 @@ def regenerate_secondary_key( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.regenerate_secondary_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'accessName': self._serialize.url("access_name", access_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) 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 + 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 9695735316ba5..7aa6beacc9dc2 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 @@ -5,23 +5,346 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # 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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + access_name: Union[str, "_models.AccessIdName"], + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + access_name: Union[str, "_models.AccessIdName"], + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_request( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_regenerate_primary_key_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + access_name: Union[str, "_models.AccessIdName"], + **kwargs: Any +) -> HttpRequest: + 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}/regeneratePrimaryKey') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_regenerate_secondary_key_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + access_name: Union[str, "_models.AccessIdName"], + **kwargs: Any +) -> HttpRequest: + 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}/regenerateSecondaryKey') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_list_secrets_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + access_name: Union[str, "_models.AccessIdName"], + **kwargs: Any +) -> HttpRequest: + 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}/listSecrets') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,14 +368,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessInformationCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AccessInformationCollection"]: """Returns list of access infos - for Git and Management endpoints. :param resource_group_name: The name of the resource group. @@ -62,8 +385,10 @@ def list_by_service( :param filter: Not used. :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 cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AccessInformationCollection] + :return: An iterator like instance of either AccessInformationCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AccessInformationCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationCollection"] @@ -71,38 +396,35 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessInformationCollection', pipeline_response) + deserialized = self._deserialize("AccessInformationCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,25 +437,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - access_name, # type: Union[str, "_models.AccessIdName"] - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -152,53 +475,45 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'accessName': self._serialize.url("access_name", access_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - access_name, # type: Union[str, "_models.AccessIdName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessInformationContract" + 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. @@ -217,56 +532,49 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'accessName': self._serialize.url("access_name", access_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AccessInformationContract', pipeline_response) 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 + + @distributed_trace def create( self, - resource_group_name, # type: str - service_name, # type: str - access_name, # type: Union[str, "_models.AccessIdName"] - if_match, # type: str - parameters, # type: "_models.AccessInformationCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessInformationContract" + resource_group_name: str, + service_name: str, + access_name: Union[str, "_models.AccessIdName"], + if_match: str, + parameters: "_models.AccessInformationCreateParameters", + **kwargs: Any + ) -> "_models.AccessInformationContract": """Update tenant access information details. :param resource_group_name: The name of the resource group. @@ -290,62 +598,55 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("access_name", access_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AccessInformationCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AccessInformationContract', pipeline_response) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - access_name, # type: Union[str, "_models.AccessIdName"] - if_match, # type: str - parameters, # type: "_models.AccessInformationUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessInformationContract" + resource_group_name: str, + service_name: str, + access_name: Union[str, "_models.AccessIdName"], + if_match: str, + parameters: "_models.AccessInformationUpdateParameters", + **kwargs: Any + ) -> "_models.AccessInformationContract": """Update tenant access information details. :param resource_group_name: The name of the resource group. @@ -369,60 +670,53 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("access_name", access_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AccessInformationUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AccessInformationContract', pipeline_response) 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 + + @distributed_trace def regenerate_primary_key( self, - resource_group_name, # type: str - service_name, # type: str - access_name, # type: Union[str, "_models.AccessIdName"] - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -441,34 +735,24 @@ def regenerate_primary_key( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.regenerate_primary_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'accessName': self._serialize.url("access_name", access_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -476,14 +760,15 @@ def regenerate_primary_key( 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, # type: str - service_name, # type: str - access_name, # type: Union[str, "_models.AccessIdName"] - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -502,34 +787,24 @@ def regenerate_secondary_key( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.regenerate_secondary_key.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'accessName': self._serialize.url("access_name", access_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -537,14 +812,15 @@ def regenerate_secondary_key( 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, # type: str - service_name, # type: str - access_name, # type: Union[str, "_models.AccessIdName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessInformationSecretsContract" + 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. @@ -563,42 +839,35 @@ def list_secrets( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_secrets.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'accessName': self._serialize.url("access_name", access_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AccessInformationSecretsContract', pipeline_response) 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 + 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 342116b8bd21d..3e3c7a83caeb9 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 @@ -5,24 +5,202 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_deploy_request_initial( + resource_group_name: str, + service_name: str, + 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] + + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_save_request_initial( + resource_group_name: str, + service_name: str, + 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] + + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_validate_request_initial( + resource_group_name: str, + service_name: str, + 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] + + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_sync_state_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + configuration_name: Union[str, "_models.ConfigurationIdName"], + **kwargs: Any +) -> HttpRequest: + 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}/syncState') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -48,52 +226,40 @@ def __init__(self, client, config, serializer, deserializer): def _deploy_initial( self, - resource_group_name, # type: str - service_name, # type: str - configuration_name, # type: Union[str, "_models.ConfigurationIdName"] - parameters, # type: "_models.DeployConfigurationParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.OperationResultContract"] + resource_group_name: str, + service_name: str, + configuration_name: Union[str, "_models.ConfigurationIdName"], + parameters: "_models.DeployConfigurationParameters", + **kwargs: Any + ) -> Optional["_models.OperationResultContract"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResultContract"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._deploy_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeployConfigurationParameters') + + request = build_deploy_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + configuration_name=configuration_name, + content_type=content_type, + json=_json, + template_url=self._deploy_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeployConfigurationParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -103,17 +269,19 @@ def _deploy_initial( 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 + + @distributed_trace def begin_deploy( self, - resource_group_name, # type: str - service_name, # type: str - configuration_name, # type: Union[str, "_models.ConfigurationIdName"] - parameters, # type: "_models.DeployConfigurationParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.OperationResultContract"] + resource_group_name: str, + service_name: str, + configuration_name: Union[str, "_models.ConfigurationIdName"], + parameters: "_models.DeployConfigurationParameters", + **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. @@ -127,15 +295,19 @@ def begin_deploy( :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters :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. + :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) + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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', @@ -148,28 +320,21 @@ def begin_deploy( service_name=service_name, configuration_name=configuration_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('OperationResultContract', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -181,56 +346,45 @@ def get_long_running_output(pipeline_response): ) else: 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 def _save_initial( self, - resource_group_name, # type: str - service_name, # type: str - configuration_name, # type: Union[str, "_models.ConfigurationIdName"] - parameters, # type: "_models.SaveConfigurationParameter" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.OperationResultContract"] + resource_group_name: str, + service_name: str, + configuration_name: Union[str, "_models.ConfigurationIdName"], + parameters: "_models.SaveConfigurationParameter", + **kwargs: Any + ) -> Optional["_models.OperationResultContract"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResultContract"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._save_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SaveConfigurationParameter') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_save_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + configuration_name=configuration_name, + content_type=content_type, + json=_json, + template_url=self._save_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SaveConfigurationParameter') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -240,17 +394,19 @@ def _save_initial( 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 + + @distributed_trace def begin_save( self, - resource_group_name, # type: str - service_name, # type: str - configuration_name, # type: Union[str, "_models.ConfigurationIdName"] - parameters, # type: "_models.SaveConfigurationParameter" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.OperationResultContract"] + resource_group_name: str, + service_name: str, + configuration_name: Union[str, "_models.ConfigurationIdName"], + parameters: "_models.SaveConfigurationParameter", + **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. @@ -264,15 +420,19 @@ def begin_save( :type parameters: ~azure.mgmt.apimanagement.models.SaveConfigurationParameter :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. + :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) + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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', @@ -285,28 +445,21 @@ def begin_save( service_name=service_name, configuration_name=configuration_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('OperationResultContract', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -318,56 +471,45 @@ def get_long_running_output(pipeline_response): ) else: 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 def _validate_initial( self, - resource_group_name, # type: str - service_name, # type: str - configuration_name, # type: Union[str, "_models.ConfigurationIdName"] - parameters, # type: "_models.DeployConfigurationParameters" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.OperationResultContract"] + resource_group_name: str, + service_name: str, + configuration_name: Union[str, "_models.ConfigurationIdName"], + parameters: "_models.DeployConfigurationParameters", + **kwargs: Any + ) -> Optional["_models.OperationResultContract"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResultContract"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._validate_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'DeployConfigurationParameters') + + request = build_validate_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + configuration_name=configuration_name, + content_type=content_type, + json=_json, + template_url=self._validate_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DeployConfigurationParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -377,17 +519,19 @@ def _validate_initial( 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 + + @distributed_trace def begin_validate( self, - resource_group_name, # type: str - service_name, # type: str - configuration_name, # type: Union[str, "_models.ConfigurationIdName"] - parameters, # type: "_models.DeployConfigurationParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.OperationResultContract"] + resource_group_name: str, + service_name: str, + configuration_name: Union[str, "_models.ConfigurationIdName"], + parameters: "_models.DeployConfigurationParameters", + **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. @@ -401,15 +545,19 @@ def begin_validate( :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters :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. + :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) + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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', @@ -422,28 +570,21 @@ def begin_validate( service_name=service_name, configuration_name=configuration_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('OperationResultContract', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + 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 cont_token: @@ -455,16 +596,17 @@ def get_long_running_output(pipeline_response): ) else: 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 + @distributed_trace def get_sync_state( self, - resource_group_name, # type: str - service_name, # type: str - configuration_name, # type: Union[str, "_models.ConfigurationIdName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.TenantConfigurationSyncStateContract" + resource_group_name: str, + service_name: str, + configuration_name: Union[str, "_models.ConfigurationIdName"], + **kwargs: Any + ) -> "_models.TenantConfigurationSyncStateContract": """Gets the status of the most recent synchronization between the configuration database and the Git repository. @@ -484,34 +626,24 @@ def get_sync_state( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_sync_state.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TenantConfigurationSyncStateContract', pipeline_response) @@ -520,4 +652,6 @@ def get_sync_state( 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 + 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 575f7aeb5917a..4ec695cfc2ed4 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 @@ -5,23 +5,101 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace 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') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_list_by_service_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # 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') + + # 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_get_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + settings_type: Union[str, "_models.SettingsTypeName"], + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings/{settingsType}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,14 +123,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TenantSettingsCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.TenantSettingsCollection"]: """Public settings. :param resource_group_name: The name of the resource group. @@ -62,7 +140,8 @@ def list_by_service( :param filter: Not used. :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 cls(response) + :return: An iterator like instance of either TenantSettingsCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TenantSettingsCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -71,38 +150,35 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TenantSettingsCollection', pipeline_response) + deserialized = self._deserialize("TenantSettingsCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,25 +191,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - settings_type, # type: Union[str, "_models.SettingsTypeName"] - **kwargs # type: Any - ): - # type: (...) -> "_models.TenantSettingsContract" + resource_group_name: str, + service_name: str, + settings_type: Union[str, "_models.SettingsTypeName"], + **kwargs: Any + ) -> "_models.TenantSettingsContract": """Get tenant settings. :param resource_group_name: The name of the resource group. @@ -152,42 +229,35 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'settingsType': self._serialize.url("settings_type", settings_type, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TenantSettingsContract', pipeline_response) 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 + 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 6969f1bc790a0..d434b98895c5e 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 @@ -5,22 +5,65 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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, + **kwargs: Any +) -> HttpRequest: + 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}/confirmations/password/send') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + + # 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. @@ -44,15 +87,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def send( self, - resource_group_name, # type: str - service_name, # type: str - user_id, # type: str - app_type=None, # type: Optional[Union[str, "_models.AppType"]] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + user_id: str, + app_type: Optional[Union[str, "_models.AppType"]] = None, + **kwargs: Any + ) -> None: """Sends confirmation. :param resource_group_name: The name of the resource group. @@ -74,39 +117,29 @@ def send( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.send.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if app_type is not None: - query_parameters['appType'] = self._serialize.query("app_type", app_type, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) 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 + 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 afd81c5eeff00..e685cc2aad848 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 @@ -5,23 +5,72 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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}/groups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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. @@ -45,17 +94,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - service_name, # type: str - user_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GroupCollection"] + resource_group_name: str, + service_name: str, + user_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.GroupCollection"]: """Lists all user groups. :param resource_group_name: The name of the resource group. @@ -86,43 +135,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('GroupCollection', pipeline_response) + deserialized = self._deserialize("GroupCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -135,12 +182,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_identities_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_identities_operations.py index 5034ae7c5dc92..854b03e8f0a39 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 @@ -5,23 +5,62 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _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 +) -> HttpRequest: + 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}/identities') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,14 +84,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - service_name, # type: str - user_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UserIdentityCollection"] + resource_group_name: str, + service_name: str, + user_id: str, + **kwargs: Any + ) -> Iterable["_models.UserIdentityCollection"]: """List of all user identities. :param resource_group_name: The name of the resource group. @@ -62,7 +101,8 @@ def list( :param user_id: User identifier. Must be unique in the current API Management service instance. :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 cls(response) + :return: An iterator like instance of either UserIdentityCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.UserIdentityCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -71,37 +111,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UserIdentityCollection', pipeline_response) + deserialized = self._deserialize("UserIdentityCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -114,12 +152,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_operations.py index e5e68f337f1b0..837cdb1506e53 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 @@ -5,23 +5,380 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + expand_groups: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$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') + + # 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_get_entity_tag_request( + resource_group_name: str, + service_name: str, + user_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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, + user_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_create_or_update_request( + resource_group_name: str, + service_name: str, + 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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # 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') + + # 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') + 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( + resource_group_name: str, + service_name: str, + user_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] + + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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') + 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_delete_request( + resource_group_name: str, + service_name: str, + user_id: str, + subscription_id: str, + *, + if_match: str, + delete_subscriptions: Optional[bool] = None, + notify: Optional[bool] = None, + app_type: Optional[Union[str, "_models.AppType"]] = None, + **kwargs: Any +) -> HttpRequest: + 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}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # 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') + if notify is not None: + query_parameters['notify'] = _SERIALIZER.query("notify", notify, 'bool') + query_parameters['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') + + # 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 + ) + + +def build_generate_sso_url_request( + resource_group_name: str, + service_name: str, + user_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + 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}/generateSsoUrl') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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_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 +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + 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') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,17 +402,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_service( self, - resource_group_name, # type: str - service_name, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - expand_groups=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UserCollection"] + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + expand_groups: Optional[bool] = None, + **kwargs: Any + ) -> Iterable["_models.UserCollection"]: """Lists a collection of registered users in the specified service instance. :param resource_group_name: The name of the resource group. @@ -88,44 +445,41 @@ def list_by_service( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_service.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - if expand_groups is not None: - query_parameters['expandGroups'] = self._serialize.query("expand_groups", expand_groups, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list_by_service.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UserCollection', pipeline_response) + deserialized = self._deserialize("UserCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -138,25 +492,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - user_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool + 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. @@ -175,53 +530,45 @@ def get_entity_tag( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_entity_tag.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.head(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + if cls: return cls(pipeline_response, None, response_headers) - return 200 <= response.status_code <= 299 + 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, # type: str - service_name, # type: str - user_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.UserContract" + 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. @@ -240,57 +587,50 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('UserContract', pipeline_response) 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 + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_name, # type: str - user_id, # type: str - parameters, # type: "_models.UserCreateParameters" - notify=None, # type: Optional[bool] - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.UserContract" + resource_group_name: str, + service_name: str, + user_id: str, + parameters: "_models.UserCreateParameters", + notify: Optional[bool] = None, + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.UserContract": """Creates or Updates a user. :param resource_group_name: The name of the resource group. @@ -316,70 +656,62 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if notify is not None: - query_parameters['notify'] = self._serialize.query("notify", notify, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UserCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + 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) 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 + + @distributed_trace def update( self, - resource_group_name, # type: str - service_name, # type: str - user_id, # type: str - if_match, # type: str - parameters, # type: "_models.UserUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.UserContract" + resource_group_name: str, + service_name: str, + user_id: str, + if_match: str, + parameters: "_models.UserUpdateParameters", + **kwargs: Any + ) -> "_models.UserContract": """Updates the details of the user specified by its identifier. :param resource_group_name: The name of the resource group. @@ -403,64 +735,57 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UserUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _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, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('UserContract', pipeline_response) 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 + + @distributed_trace def delete( self, - resource_group_name, # type: str - service_name, # type: str - user_id, # type: str - if_match, # type: str - delete_subscriptions=None, # type: Optional[bool] - notify=None, # type: Optional[bool] - app_type=None, # type: Optional[Union[str, "_models.AppType"]] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_name: str, + user_id: str, + if_match: str, + delete_subscriptions: Optional[bool] = None, + notify: Optional[bool] = None, + app_type: Optional[Union[str, "_models.AppType"]] = None, + **kwargs: Any + ) -> None: """Deletes specific user. :param resource_group_name: The name of the resource group. @@ -489,41 +814,28 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if delete_subscriptions is not None: - query_parameters['deleteSubscriptions'] = self._serialize.query("delete_subscriptions", delete_subscriptions, 'bool') - if notify is not None: - query_parameters['notify'] = self._serialize.query("notify", notify, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if app_type is not None: - query_parameters['appType'] = self._serialize.query("app_type", app_type, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) + + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + if_match=if_match, + delete_subscriptions=delete_subscriptions, + notify=notify, + app_type=app_type, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -531,14 +843,15 @@ def delete( 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, # type: str - service_name, # type: str - user_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GenerateSsoUrlResult" + 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. @@ -558,34 +871,24 @@ def generate_sso_url( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.generate_sso_url.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GenerateSsoUrlResult', pipeline_response) @@ -594,17 +897,19 @@ def generate_sso_url( 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 + + @distributed_trace def get_shared_access_token( self, - resource_group_name, # type: str - service_name, # type: str - user_id, # type: str - parameters, # type: "_models.UserTokenParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.UserTokenResult" + resource_group_name: str, + service_name: str, + user_id: str, + parameters: "_models.UserTokenParameters", + **kwargs: Any + ) -> "_models.UserTokenResult": """Gets the Shared Access Authorization Token for the User. :param resource_group_name: The name of the resource group. @@ -625,39 +930,29 @@ def get_shared_access_token( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.get_shared_access_token.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'UserTokenParameters') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + 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, + content_type=content_type, + json=_json, + template_url=self.get_shared_access_token.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UserTokenParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UserTokenResult', pipeline_response) @@ -666,4 +961,6 @@ def get_shared_access_token( 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 + 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 e22485cdfe4ae..cd354b64fd3e2 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 @@ -5,23 +5,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace 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') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_list_request( + resource_group_name: str, + service_name: str, + user_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + 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}/subscriptions') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$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') + + # 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_get_request( + 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" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions/{sid}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("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'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['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. @@ -45,17 +133,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - service_name, # type: str - user_id, # type: str - filter=None, # type: Optional[str] - top=None, # type: Optional[int] - skip=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SubscriptionCollection"] + resource_group_name: str, + service_name: str, + user_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.SubscriptionCollection"]: """Lists the collection of subscriptions of the specified user. :param resource_group_name: The name of the resource group. @@ -80,7 +168,8 @@ def list( :param skip: Number of records to skip. :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 cls(response) + :return: An iterator like instance of either SubscriptionCollection or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.SubscriptionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -89,43 +178,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SubscriptionCollection', pipeline_response) + deserialized = self._deserialize("SubscriptionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -138,26 +225,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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, # type: str - service_name, # type: str - user_id, # type: str - sid, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SubscriptionContract" + 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. @@ -179,43 +267,36 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("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': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'sid': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SubscriptionContract', pipeline_response) 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 +