diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/_meta.json b/sdk/apimanagement/azure-mgmt-apimanagement/_meta.json index 1208e022ae8a..484c79b18ea9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/_meta.json +++ b/sdk/apimanagement/azure-mgmt-apimanagement/_meta.json @@ -1,11 +1,11 @@ { "autorest": "3.7.2", "use": [ - "@autorest/python@5.12.0", + "@autorest/python@5.16.0", "@autorest/modelerfour@4.19.3" ], - "commit": "0b70eafc6469141d5c4dc868c4a4438db6c32ead", + "commit": "6d30983b12677ad4f1d2c57050791ba5883890fc", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/apimanagement/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/apimanagement/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.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 80f492a921b4..f47c2720e0cf 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/__init__.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['ApiManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.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() +_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 076c212079e5..db195b5f9a24 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_api_management_client.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_api_management_client.py @@ -7,192 +7,215 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import ApiManagementClientConfiguration -from .operations import ApiDiagnosticOperations, ApiExportOperations, ApiIssueAttachmentOperations, ApiIssueCommentOperations, ApiIssueOperations, ApiManagementClientOperationsMixin, ApiManagementOperationsOperations, ApiManagementServiceOperations, ApiManagementServiceSkusOperations, ApiManagementSkusOperations, ApiOperationOperations, ApiOperationPolicyOperations, ApiOperations, ApiPolicyOperations, ApiProductOperations, ApiReleaseOperations, ApiRevisionOperations, ApiSchemaOperations, ApiTagDescriptionOperations, ApiVersionSetOperations, AuthorizationServerOperations, BackendOperations, CacheOperations, CertificateOperations, ContentItemOperations, ContentTypeOperations, DelegationSettingsOperations, DeletedServicesOperations, DiagnosticOperations, EmailTemplateOperations, GatewayApiOperations, GatewayCertificateAuthorityOperations, GatewayHostnameConfigurationOperations, GatewayOperations, GlobalSchemaOperations, GroupOperations, GroupUserOperations, IdentityProviderOperations, IssueOperations, LoggerOperations, NamedValueOperations, NetworkStatusOperations, NotificationOperations, NotificationRecipientEmailOperations, NotificationRecipientUserOperations, OpenIdConnectProviderOperations, OperationOperations, OutboundNetworkDependenciesEndpointsOperations, PolicyDescriptionOperations, PolicyOperations, PortalRevisionOperations, PortalSettingsOperations, PrivateEndpointConnectionOperations, ProductApiOperations, ProductGroupOperations, ProductOperations, ProductPolicyOperations, ProductSubscriptionsOperations, QuotaByCounterKeysOperations, QuotaByPeriodKeysOperations, RegionOperations, ReportsOperations, SignInSettingsOperations, SignUpSettingsOperations, SubscriptionOperations, TagOperations, TagResourceOperations, TenantAccessGitOperations, TenantAccessOperations, TenantConfigurationOperations, TenantSettingsOperations, UserConfirmationPasswordOperations, UserGroupOperations, UserIdentitiesOperations, UserOperations, UserSubscriptionOperations +from .operations import ApiDiagnosticOperations, ApiExportOperations, ApiIssueAttachmentOperations, ApiIssueCommentOperations, ApiIssueOperations, ApiManagementClientOperationsMixin, ApiManagementOperationsOperations, ApiManagementServiceOperations, ApiManagementServiceSkusOperations, ApiManagementSkusOperations, ApiOperationOperations, ApiOperationPolicyOperations, ApiOperations, ApiPolicyOperations, ApiProductOperations, ApiReleaseOperations, ApiRevisionOperations, ApiSchemaOperations, ApiTagDescriptionOperations, ApiVersionSetOperations, AuthorizationAccessPolicyOperations, AuthorizationLoginLinksOperations, AuthorizationOperations, AuthorizationProviderOperations, 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, PolicyFragmentOperations, PolicyOperations, PortalConfigOperations, PortalRevisionOperations, PortalSettingsOperations, PrivateEndpointConnectionOperations, ProductApiOperations, ProductGroupOperations, ProductOperations, ProductPolicyOperations, ProductSubscriptionsOperations, QuotaByCounterKeysOperations, QuotaByPeriodKeysOperations, RegionOperations, ReportsOperations, SignInSettingsOperations, SignUpSettingsOperations, SubscriptionOperations, TagOperations, TagResourceOperations, TenantAccessGitOperations, TenantAccessOperations, TenantConfigurationOperations, TenantSettingsOperations, UserConfirmationPasswordOperations, UserGroupOperations, UserIdentitiesOperations, UserOperations, UserSubscriptionOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ApiManagementClient(ApiManagementClientOperationsMixin): +class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disable=too-many-instance-attributes """ApiManagement Client. :ivar api: ApiOperations operations - :vartype api: api_management_client.operations.ApiOperations + :vartype api: azure.mgmt.apimanagement.operations.ApiOperations :ivar api_revision: ApiRevisionOperations operations - :vartype api_revision: api_management_client.operations.ApiRevisionOperations + :vartype api_revision: azure.mgmt.apimanagement.operations.ApiRevisionOperations :ivar api_release: ApiReleaseOperations operations - :vartype api_release: api_management_client.operations.ApiReleaseOperations + :vartype api_release: azure.mgmt.apimanagement.operations.ApiReleaseOperations :ivar api_operation: ApiOperationOperations operations - :vartype api_operation: api_management_client.operations.ApiOperationOperations + :vartype api_operation: azure.mgmt.apimanagement.operations.ApiOperationOperations :ivar api_operation_policy: ApiOperationPolicyOperations operations - :vartype api_operation_policy: api_management_client.operations.ApiOperationPolicyOperations + :vartype api_operation_policy: azure.mgmt.apimanagement.operations.ApiOperationPolicyOperations :ivar tag: TagOperations operations - :vartype tag: api_management_client.operations.TagOperations + :vartype tag: azure.mgmt.apimanagement.operations.TagOperations :ivar api_product: ApiProductOperations operations - :vartype api_product: api_management_client.operations.ApiProductOperations + :vartype api_product: azure.mgmt.apimanagement.operations.ApiProductOperations :ivar api_policy: ApiPolicyOperations operations - :vartype api_policy: api_management_client.operations.ApiPolicyOperations + :vartype api_policy: azure.mgmt.apimanagement.operations.ApiPolicyOperations :ivar api_schema: ApiSchemaOperations operations - :vartype api_schema: api_management_client.operations.ApiSchemaOperations + :vartype api_schema: azure.mgmt.apimanagement.operations.ApiSchemaOperations :ivar api_diagnostic: ApiDiagnosticOperations operations - :vartype api_diagnostic: api_management_client.operations.ApiDiagnosticOperations + :vartype api_diagnostic: azure.mgmt.apimanagement.operations.ApiDiagnosticOperations :ivar api_issue: ApiIssueOperations operations - :vartype api_issue: api_management_client.operations.ApiIssueOperations + :vartype api_issue: azure.mgmt.apimanagement.operations.ApiIssueOperations :ivar api_issue_comment: ApiIssueCommentOperations operations - :vartype api_issue_comment: api_management_client.operations.ApiIssueCommentOperations + :vartype api_issue_comment: azure.mgmt.apimanagement.operations.ApiIssueCommentOperations :ivar api_issue_attachment: ApiIssueAttachmentOperations operations - :vartype api_issue_attachment: api_management_client.operations.ApiIssueAttachmentOperations + :vartype api_issue_attachment: azure.mgmt.apimanagement.operations.ApiIssueAttachmentOperations :ivar api_tag_description: ApiTagDescriptionOperations operations - :vartype api_tag_description: api_management_client.operations.ApiTagDescriptionOperations + :vartype api_tag_description: azure.mgmt.apimanagement.operations.ApiTagDescriptionOperations :ivar operation: OperationOperations operations - :vartype operation: api_management_client.operations.OperationOperations + :vartype operation: azure.mgmt.apimanagement.operations.OperationOperations :ivar api_export: ApiExportOperations operations - :vartype api_export: api_management_client.operations.ApiExportOperations + :vartype api_export: azure.mgmt.apimanagement.operations.ApiExportOperations :ivar api_version_set: ApiVersionSetOperations operations - :vartype api_version_set: api_management_client.operations.ApiVersionSetOperations + :vartype api_version_set: azure.mgmt.apimanagement.operations.ApiVersionSetOperations :ivar authorization_server: AuthorizationServerOperations operations - :vartype authorization_server: api_management_client.operations.AuthorizationServerOperations + :vartype authorization_server: + azure.mgmt.apimanagement.operations.AuthorizationServerOperations + :ivar authorization_provider: AuthorizationProviderOperations operations + :vartype authorization_provider: + azure.mgmt.apimanagement.operations.AuthorizationProviderOperations + :ivar authorization: AuthorizationOperations operations + :vartype authorization: azure.mgmt.apimanagement.operations.AuthorizationOperations + :ivar authorization_login_links: AuthorizationLoginLinksOperations operations + :vartype authorization_login_links: + azure.mgmt.apimanagement.operations.AuthorizationLoginLinksOperations + :ivar authorization_access_policy: AuthorizationAccessPolicyOperations operations + :vartype authorization_access_policy: + azure.mgmt.apimanagement.operations.AuthorizationAccessPolicyOperations :ivar backend: BackendOperations operations - :vartype backend: api_management_client.operations.BackendOperations + :vartype backend: azure.mgmt.apimanagement.operations.BackendOperations :ivar cache: CacheOperations operations - :vartype cache: api_management_client.operations.CacheOperations + :vartype cache: azure.mgmt.apimanagement.operations.CacheOperations :ivar certificate: CertificateOperations operations - :vartype certificate: api_management_client.operations.CertificateOperations + :vartype certificate: azure.mgmt.apimanagement.operations.CertificateOperations :ivar content_type: ContentTypeOperations operations - :vartype content_type: api_management_client.operations.ContentTypeOperations + :vartype content_type: azure.mgmt.apimanagement.operations.ContentTypeOperations :ivar content_item: ContentItemOperations operations - :vartype content_item: api_management_client.operations.ContentItemOperations + :vartype content_item: azure.mgmt.apimanagement.operations.ContentItemOperations :ivar deleted_services: DeletedServicesOperations operations - :vartype deleted_services: api_management_client.operations.DeletedServicesOperations + :vartype deleted_services: azure.mgmt.apimanagement.operations.DeletedServicesOperations :ivar api_management_operations: ApiManagementOperationsOperations operations :vartype api_management_operations: - api_management_client.operations.ApiManagementOperationsOperations + azure.mgmt.apimanagement.operations.ApiManagementOperationsOperations :ivar api_management_service_skus: ApiManagementServiceSkusOperations operations :vartype api_management_service_skus: - api_management_client.operations.ApiManagementServiceSkusOperations + azure.mgmt.apimanagement.operations.ApiManagementServiceSkusOperations :ivar api_management_service: ApiManagementServiceOperations operations :vartype api_management_service: - api_management_client.operations.ApiManagementServiceOperations + azure.mgmt.apimanagement.operations.ApiManagementServiceOperations :ivar diagnostic: DiagnosticOperations operations - :vartype diagnostic: api_management_client.operations.DiagnosticOperations + :vartype diagnostic: azure.mgmt.apimanagement.operations.DiagnosticOperations :ivar email_template: EmailTemplateOperations operations - :vartype email_template: api_management_client.operations.EmailTemplateOperations + :vartype email_template: azure.mgmt.apimanagement.operations.EmailTemplateOperations :ivar gateway: GatewayOperations operations - :vartype gateway: api_management_client.operations.GatewayOperations + :vartype gateway: azure.mgmt.apimanagement.operations.GatewayOperations :ivar gateway_hostname_configuration: GatewayHostnameConfigurationOperations operations :vartype gateway_hostname_configuration: - api_management_client.operations.GatewayHostnameConfigurationOperations + azure.mgmt.apimanagement.operations.GatewayHostnameConfigurationOperations :ivar gateway_api: GatewayApiOperations operations - :vartype gateway_api: api_management_client.operations.GatewayApiOperations + :vartype gateway_api: azure.mgmt.apimanagement.operations.GatewayApiOperations :ivar gateway_certificate_authority: GatewayCertificateAuthorityOperations operations :vartype gateway_certificate_authority: - api_management_client.operations.GatewayCertificateAuthorityOperations + azure.mgmt.apimanagement.operations.GatewayCertificateAuthorityOperations :ivar group: GroupOperations operations - :vartype group: api_management_client.operations.GroupOperations + :vartype group: azure.mgmt.apimanagement.operations.GroupOperations :ivar group_user: GroupUserOperations operations - :vartype group_user: api_management_client.operations.GroupUserOperations + :vartype group_user: azure.mgmt.apimanagement.operations.GroupUserOperations :ivar identity_provider: IdentityProviderOperations operations - :vartype identity_provider: api_management_client.operations.IdentityProviderOperations + :vartype identity_provider: azure.mgmt.apimanagement.operations.IdentityProviderOperations :ivar issue: IssueOperations operations - :vartype issue: api_management_client.operations.IssueOperations + :vartype issue: azure.mgmt.apimanagement.operations.IssueOperations :ivar logger: LoggerOperations operations - :vartype logger: api_management_client.operations.LoggerOperations + :vartype logger: azure.mgmt.apimanagement.operations.LoggerOperations :ivar named_value: NamedValueOperations operations - :vartype named_value: api_management_client.operations.NamedValueOperations + :vartype named_value: azure.mgmt.apimanagement.operations.NamedValueOperations :ivar network_status: NetworkStatusOperations operations - :vartype network_status: api_management_client.operations.NetworkStatusOperations + :vartype network_status: azure.mgmt.apimanagement.operations.NetworkStatusOperations :ivar notification: NotificationOperations operations - :vartype notification: api_management_client.operations.NotificationOperations + :vartype notification: azure.mgmt.apimanagement.operations.NotificationOperations :ivar notification_recipient_user: NotificationRecipientUserOperations operations :vartype notification_recipient_user: - api_management_client.operations.NotificationRecipientUserOperations + azure.mgmt.apimanagement.operations.NotificationRecipientUserOperations :ivar notification_recipient_email: NotificationRecipientEmailOperations operations :vartype notification_recipient_email: - api_management_client.operations.NotificationRecipientEmailOperations + azure.mgmt.apimanagement.operations.NotificationRecipientEmailOperations :ivar open_id_connect_provider: OpenIdConnectProviderOperations operations :vartype open_id_connect_provider: - api_management_client.operations.OpenIdConnectProviderOperations + azure.mgmt.apimanagement.operations.OpenIdConnectProviderOperations :ivar outbound_network_dependencies_endpoints: OutboundNetworkDependenciesEndpointsOperations operations :vartype outbound_network_dependencies_endpoints: - api_management_client.operations.OutboundNetworkDependenciesEndpointsOperations + azure.mgmt.apimanagement.operations.OutboundNetworkDependenciesEndpointsOperations :ivar policy: PolicyOperations operations - :vartype policy: api_management_client.operations.PolicyOperations + :vartype policy: azure.mgmt.apimanagement.operations.PolicyOperations :ivar policy_description: PolicyDescriptionOperations operations - :vartype policy_description: api_management_client.operations.PolicyDescriptionOperations + :vartype policy_description: azure.mgmt.apimanagement.operations.PolicyDescriptionOperations + :ivar policy_fragment: PolicyFragmentOperations operations + :vartype policy_fragment: azure.mgmt.apimanagement.operations.PolicyFragmentOperations + :ivar portal_config: PortalConfigOperations operations + :vartype portal_config: azure.mgmt.apimanagement.operations.PortalConfigOperations :ivar portal_revision: PortalRevisionOperations operations - :vartype portal_revision: api_management_client.operations.PortalRevisionOperations + :vartype portal_revision: azure.mgmt.apimanagement.operations.PortalRevisionOperations :ivar portal_settings: PortalSettingsOperations operations - :vartype portal_settings: api_management_client.operations.PortalSettingsOperations + :vartype portal_settings: azure.mgmt.apimanagement.operations.PortalSettingsOperations :ivar sign_in_settings: SignInSettingsOperations operations - :vartype sign_in_settings: api_management_client.operations.SignInSettingsOperations + :vartype sign_in_settings: azure.mgmt.apimanagement.operations.SignInSettingsOperations :ivar sign_up_settings: SignUpSettingsOperations operations - :vartype sign_up_settings: api_management_client.operations.SignUpSettingsOperations + :vartype sign_up_settings: azure.mgmt.apimanagement.operations.SignUpSettingsOperations :ivar delegation_settings: DelegationSettingsOperations operations - :vartype delegation_settings: api_management_client.operations.DelegationSettingsOperations + :vartype delegation_settings: azure.mgmt.apimanagement.operations.DelegationSettingsOperations :ivar private_endpoint_connection: PrivateEndpointConnectionOperations operations :vartype private_endpoint_connection: - api_management_client.operations.PrivateEndpointConnectionOperations + azure.mgmt.apimanagement.operations.PrivateEndpointConnectionOperations :ivar product: ProductOperations operations - :vartype product: api_management_client.operations.ProductOperations + :vartype product: azure.mgmt.apimanagement.operations.ProductOperations :ivar product_api: ProductApiOperations operations - :vartype product_api: api_management_client.operations.ProductApiOperations + :vartype product_api: azure.mgmt.apimanagement.operations.ProductApiOperations :ivar product_group: ProductGroupOperations operations - :vartype product_group: api_management_client.operations.ProductGroupOperations + :vartype product_group: azure.mgmt.apimanagement.operations.ProductGroupOperations :ivar product_subscriptions: ProductSubscriptionsOperations operations - :vartype product_subscriptions: api_management_client.operations.ProductSubscriptionsOperations + :vartype product_subscriptions: + azure.mgmt.apimanagement.operations.ProductSubscriptionsOperations :ivar product_policy: ProductPolicyOperations operations - :vartype product_policy: api_management_client.operations.ProductPolicyOperations + :vartype product_policy: azure.mgmt.apimanagement.operations.ProductPolicyOperations :ivar quota_by_counter_keys: QuotaByCounterKeysOperations operations - :vartype quota_by_counter_keys: api_management_client.operations.QuotaByCounterKeysOperations + :vartype quota_by_counter_keys: + azure.mgmt.apimanagement.operations.QuotaByCounterKeysOperations :ivar quota_by_period_keys: QuotaByPeriodKeysOperations operations - :vartype quota_by_period_keys: api_management_client.operations.QuotaByPeriodKeysOperations + :vartype quota_by_period_keys: azure.mgmt.apimanagement.operations.QuotaByPeriodKeysOperations :ivar region: RegionOperations operations - :vartype region: api_management_client.operations.RegionOperations + :vartype region: azure.mgmt.apimanagement.operations.RegionOperations :ivar reports: ReportsOperations operations - :vartype reports: api_management_client.operations.ReportsOperations + :vartype reports: azure.mgmt.apimanagement.operations.ReportsOperations :ivar global_schema: GlobalSchemaOperations operations - :vartype global_schema: api_management_client.operations.GlobalSchemaOperations + :vartype global_schema: azure.mgmt.apimanagement.operations.GlobalSchemaOperations :ivar tenant_settings: TenantSettingsOperations operations - :vartype tenant_settings: api_management_client.operations.TenantSettingsOperations + :vartype tenant_settings: azure.mgmt.apimanagement.operations.TenantSettingsOperations :ivar api_management_skus: ApiManagementSkusOperations operations - :vartype api_management_skus: api_management_client.operations.ApiManagementSkusOperations + :vartype api_management_skus: azure.mgmt.apimanagement.operations.ApiManagementSkusOperations :ivar subscription: SubscriptionOperations operations - :vartype subscription: api_management_client.operations.SubscriptionOperations + :vartype subscription: azure.mgmt.apimanagement.operations.SubscriptionOperations :ivar tag_resource: TagResourceOperations operations - :vartype tag_resource: api_management_client.operations.TagResourceOperations + :vartype tag_resource: azure.mgmt.apimanagement.operations.TagResourceOperations :ivar tenant_access: TenantAccessOperations operations - :vartype tenant_access: api_management_client.operations.TenantAccessOperations + :vartype tenant_access: azure.mgmt.apimanagement.operations.TenantAccessOperations :ivar tenant_access_git: TenantAccessGitOperations operations - :vartype tenant_access_git: api_management_client.operations.TenantAccessGitOperations + :vartype tenant_access_git: azure.mgmt.apimanagement.operations.TenantAccessGitOperations :ivar tenant_configuration: TenantConfigurationOperations operations - :vartype tenant_configuration: api_management_client.operations.TenantConfigurationOperations + :vartype tenant_configuration: + azure.mgmt.apimanagement.operations.TenantConfigurationOperations :ivar user: UserOperations operations - :vartype user: api_management_client.operations.UserOperations + :vartype user: azure.mgmt.apimanagement.operations.UserOperations :ivar user_group: UserGroupOperations operations - :vartype user_group: api_management_client.operations.UserGroupOperations + :vartype user_group: azure.mgmt.apimanagement.operations.UserGroupOperations :ivar user_subscription: UserSubscriptionOperations operations - :vartype user_subscription: api_management_client.operations.UserSubscriptionOperations + :vartype user_subscription: azure.mgmt.apimanagement.operations.UserSubscriptionOperations :ivar user_identities: UserIdentitiesOperations operations - :vartype user_identities: api_management_client.operations.UserIdentitiesOperations + :vartype user_identities: azure.mgmt.apimanagement.operations.UserIdentitiesOperations :ivar user_confirmation_password: UserConfirmationPasswordOperations operations :vartype user_confirmation_password: - api_management_client.operations.UserConfirmationPasswordOperations + 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. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2022-04-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -211,86 +234,254 @@ def __init__( self._serialize = Serializer(client_models) 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.authorization_provider = AuthorizationProviderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.authorization = AuthorizationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.authorization_login_links = AuthorizationLoginLinksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.authorization_access_policy = AuthorizationAccessPolicyOperations( + 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.policy_fragment = PolicyFragmentOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.portal_config = PortalConfigOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.portal_revision = PortalRevisionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.portal_settings = PortalSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sign_in_settings = SignInSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sign_up_settings = SignUpSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.delegation_settings = DelegationSettingsOperations( + self._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 + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. 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 6644ed21cee1..f85992a4437c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_configuration.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class ApiManagementClientConfiguration(Configuration): +class ApiManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for ApiManagementClient. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class ApiManagementClientConfiguration(Configuration): :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 + :keyword api_version: Api Version. Default value is "2022-04-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +42,8 @@ def __init__( **kwargs: Any ) -> None: super(ApiManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +51,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-08-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-apimanagement/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_metadata.json b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_metadata.json deleted file mode 100644 index 4d4ecf9095d3..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_metadata.json +++ /dev/null @@ -1,206 +0,0 @@ -{ - "chosen_version": "2021-08-01", - "total_api_version_list": ["2021-08-01"], - "client": { - "name": "ApiManagementClient", - "filename": "_api_management_client", - "description": "ApiManagement Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApiManagementClientConfiguration\"], \"._operations_mixin\": [\"ApiManagementClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ApiManagementClientConfiguration\"], \"._operations_mixin\": [\"ApiManagementClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "api": "ApiOperations", - "api_revision": "ApiRevisionOperations", - "api_release": "ApiReleaseOperations", - "api_operation": "ApiOperationOperations", - "api_operation_policy": "ApiOperationPolicyOperations", - "tag": "TagOperations", - "api_product": "ApiProductOperations", - "api_policy": "ApiPolicyOperations", - "api_schema": "ApiSchemaOperations", - "api_diagnostic": "ApiDiagnosticOperations", - "api_issue": "ApiIssueOperations", - "api_issue_comment": "ApiIssueCommentOperations", - "api_issue_attachment": "ApiIssueAttachmentOperations", - "api_tag_description": "ApiTagDescriptionOperations", - "operation": "OperationOperations", - "api_export": "ApiExportOperations", - "api_version_set": "ApiVersionSetOperations", - "authorization_server": "AuthorizationServerOperations", - "backend": "BackendOperations", - "cache": "CacheOperations", - "certificate": "CertificateOperations", - "content_type": "ContentTypeOperations", - "content_item": "ContentItemOperations", - "deleted_services": "DeletedServicesOperations", - "api_management_operations": "ApiManagementOperationsOperations", - "api_management_service_skus": "ApiManagementServiceSkusOperations", - "api_management_service": "ApiManagementServiceOperations", - "diagnostic": "DiagnosticOperations", - "email_template": "EmailTemplateOperations", - "gateway": "GatewayOperations", - "gateway_hostname_configuration": "GatewayHostnameConfigurationOperations", - "gateway_api": "GatewayApiOperations", - "gateway_certificate_authority": "GatewayCertificateAuthorityOperations", - "group": "GroupOperations", - "group_user": "GroupUserOperations", - "identity_provider": "IdentityProviderOperations", - "issue": "IssueOperations", - "logger": "LoggerOperations", - "named_value": "NamedValueOperations", - "network_status": "NetworkStatusOperations", - "notification": "NotificationOperations", - "notification_recipient_user": "NotificationRecipientUserOperations", - "notification_recipient_email": "NotificationRecipientEmailOperations", - "open_id_connect_provider": "OpenIdConnectProviderOperations", - "outbound_network_dependencies_endpoints": "OutboundNetworkDependenciesEndpointsOperations", - "policy": "PolicyOperations", - "policy_description": "PolicyDescriptionOperations", - "portal_revision": "PortalRevisionOperations", - "portal_settings": "PortalSettingsOperations", - "sign_in_settings": "SignInSettingsOperations", - "sign_up_settings": "SignUpSettingsOperations", - "delegation_settings": "DelegationSettingsOperations", - "private_endpoint_connection": "PrivateEndpointConnectionOperations", - "product": "ProductOperations", - "product_api": "ProductApiOperations", - "product_group": "ProductGroupOperations", - "product_subscriptions": "ProductSubscriptionsOperations", - "product_policy": "ProductPolicyOperations", - "quota_by_counter_keys": "QuotaByCounterKeysOperations", - "quota_by_period_keys": "QuotaByPeriodKeysOperations", - "region": "RegionOperations", - "reports": "ReportsOperations", - "global_schema": "GlobalSchemaOperations", - "tenant_settings": "TenantSettingsOperations", - "api_management_skus": "ApiManagementSkusOperations", - "subscription": "SubscriptionOperations", - "tag_resource": "TagResourceOperations", - "tenant_access": "TenantAccessOperations", - "tenant_access_git": "TenantAccessGitOperations", - "tenant_configuration": "TenantConfigurationOperations", - "user": "UserOperations", - "user_group": "UserGroupOperations", - "user_subscription": "UserSubscriptionOperations", - "user_identities": "UserIdentitiesOperations", - "user_confirmation_password": "UserConfirmationPasswordOperations" - }, - "operation_mixins": { - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.polling\": [\"LROPoller\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.polling\": [\"AsyncLROPoller\"]}}}", - "operations": { - "_perform_connectivity_check_async_initial" : { - "sync": { - "signature": "def _perform_connectivity_check_async_initial(\n self,\n resource_group_name, # type: str\n service_name, # type: str\n connectivity_check_request_params, # type: \"_models.ConnectivityCheckRequest\"\n **kwargs # type: Any\n):\n # type: (...) -\u003e Optional[\"_models.ConnectivityCheckResponse\"]\n", - "doc": "\n\n:param resource_group_name: The name of the resource group.\n:type resource_group_name: str\n:param service_name: The name of the API Management service.\n:type service_name: str\n:param connectivity_check_request_params: Connectivity Check request parameters.\n:type connectivity_check_request_params: ~api_management_client.models.ConnectivityCheckRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ConnectivityCheckResponse, or the result of cls(response)\n:rtype: ~api_management_client.models.ConnectivityCheckResponse or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def _perform_connectivity_check_async_initial(\n self,\n resource_group_name: str,\n service_name: str,\n connectivity_check_request_params: \"_models.ConnectivityCheckRequest\",\n **kwargs: Any\n) -\u003e Optional[\"_models.ConnectivityCheckResponse\"]:\n", - "doc": "\n\n:param resource_group_name: The name of the resource group.\n:type resource_group_name: str\n:param service_name: The name of the API Management service.\n:type service_name: str\n:param connectivity_check_request_params: Connectivity Check request parameters.\n:type connectivity_check_request_params: ~api_management_client.models.ConnectivityCheckRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ConnectivityCheckResponse, or the result of cls(response)\n:rtype: ~api_management_client.models.ConnectivityCheckResponse or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "resource_group_name, service_name, connectivity_check_request_params" - }, - "begin_perform_connectivity_check_async" : { - "sync": { - "signature": "def begin_perform_connectivity_check_async(\n self,\n resource_group_name, # type: str\n service_name, # type: str\n connectivity_check_request_params, # type: \"_models.ConnectivityCheckRequest\"\n **kwargs # type: Any\n):\n # type: (...) -\u003e LROPoller[\"_models.ConnectivityCheckResponse\"]\n", - "doc": "\"\"\"Performs a connectivity check between the API Management service and a given destination, and\nreturns metrics for the connection, as well as errors encountered while trying to establish it.\n\n:param resource_group_name: The name of the resource group.\n:type resource_group_name: str\n:param service_name: The name of the API Management service.\n:type service_name: str\n:param connectivity_check_request_params: Connectivity Check request parameters.\n:type connectivity_check_request_params: ~api_management_client.models.ConnectivityCheckRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this\n operation to not poll, or pass in your own initialized polling object for a personal polling\n strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of LROPoller that returns either ConnectivityCheckResponse or the result\n of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~api_management_client.models.ConnectivityCheckResponse]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def begin_perform_connectivity_check_async(\n self,\n resource_group_name: str,\n service_name: str,\n connectivity_check_request_params: \"_models.ConnectivityCheckRequest\",\n **kwargs: Any\n) -\u003e AsyncLROPoller[\"_models.ConnectivityCheckResponse\"]:\n", - "doc": "\"\"\"Performs a connectivity check between the API Management service and a given destination, and\nreturns metrics for the connection, as well as errors encountered while trying to establish it.\n\n:param resource_group_name: The name of the resource group.\n:type resource_group_name: str\n:param service_name: The name of the API Management service.\n:type service_name: str\n:param connectivity_check_request_params: Connectivity Check request parameters.\n:type connectivity_check_request_params: ~api_management_client.models.ConnectivityCheckRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for\n this operation to not poll, or pass in your own initialized polling object for a personal\n polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no\n Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns either ConnectivityCheckResponse or the\n result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~api_management_client.models.ConnectivityCheckResponse]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "resource_group_name, service_name, connectivity_check_request_params" - } - } - } -} \ No newline at end of file diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_vendor.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_vendor.py index 138f663c53a4..0fce5b8cc957 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_vendor.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_vendor.py @@ -5,8 +5,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from abc import ABC +from typing import TYPE_CHECKING + from azure.core.pipeline.transport import HttpRequest +from ._configuration import ApiManagementClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import PipelineClient + 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) @@ -25,3 +36,10 @@ def _format_url_section(template, **kwargs): c for c in formatted_components if "{}".format(key.args[0]) not in c ] template = "/".join(components) + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "PipelineClient" + _config: ApiManagementClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_version.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_version.py index cac9f5d10f8b..e5754a47ce68 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_version.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/__init__.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/__init__.py index bed0fab90ba8..6ad7e882435c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/__init__.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._api_management_client import ApiManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['ApiManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.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() +_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 7d65b6a09b3f..24fbb93a99c5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_api_management_client.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_api_management_client.py @@ -7,198 +7,222 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer 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 +from .operations import ApiDiagnosticOperations, ApiExportOperations, ApiIssueAttachmentOperations, ApiIssueCommentOperations, ApiIssueOperations, ApiManagementClientOperationsMixin, ApiManagementOperationsOperations, ApiManagementServiceOperations, ApiManagementServiceSkusOperations, ApiManagementSkusOperations, ApiOperationOperations, ApiOperationPolicyOperations, ApiOperations, ApiPolicyOperations, ApiProductOperations, ApiReleaseOperations, ApiRevisionOperations, ApiSchemaOperations, ApiTagDescriptionOperations, ApiVersionSetOperations, AuthorizationAccessPolicyOperations, AuthorizationLoginLinksOperations, AuthorizationOperations, AuthorizationProviderOperations, 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, PolicyFragmentOperations, PolicyOperations, PortalConfigOperations, PortalRevisionOperations, PortalSettingsOperations, PrivateEndpointConnectionOperations, ProductApiOperations, ProductGroupOperations, ProductOperations, ProductPolicyOperations, ProductSubscriptionsOperations, QuotaByCounterKeysOperations, QuotaByPeriodKeysOperations, RegionOperations, ReportsOperations, SignInSettingsOperations, SignUpSettingsOperations, SubscriptionOperations, TagOperations, TagResourceOperations, TenantAccessGitOperations, TenantAccessOperations, TenantConfigurationOperations, TenantSettingsOperations, UserConfirmationPasswordOperations, UserGroupOperations, UserIdentitiesOperations, UserOperations, UserSubscriptionOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ApiManagementClient(ApiManagementClientOperationsMixin): +class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disable=too-many-instance-attributes """ApiManagement Client. :ivar api: ApiOperations operations - :vartype api: api_management_client.aio.operations.ApiOperations + :vartype api: azure.mgmt.apimanagement.aio.operations.ApiOperations :ivar api_revision: ApiRevisionOperations operations - :vartype api_revision: api_management_client.aio.operations.ApiRevisionOperations + :vartype api_revision: azure.mgmt.apimanagement.aio.operations.ApiRevisionOperations :ivar api_release: ApiReleaseOperations operations - :vartype api_release: api_management_client.aio.operations.ApiReleaseOperations + :vartype api_release: azure.mgmt.apimanagement.aio.operations.ApiReleaseOperations :ivar api_operation: ApiOperationOperations operations - :vartype api_operation: api_management_client.aio.operations.ApiOperationOperations + :vartype api_operation: azure.mgmt.apimanagement.aio.operations.ApiOperationOperations :ivar api_operation_policy: ApiOperationPolicyOperations operations :vartype api_operation_policy: - api_management_client.aio.operations.ApiOperationPolicyOperations + azure.mgmt.apimanagement.aio.operations.ApiOperationPolicyOperations :ivar tag: TagOperations operations - :vartype tag: api_management_client.aio.operations.TagOperations + :vartype tag: azure.mgmt.apimanagement.aio.operations.TagOperations :ivar api_product: ApiProductOperations operations - :vartype api_product: api_management_client.aio.operations.ApiProductOperations + :vartype api_product: azure.mgmt.apimanagement.aio.operations.ApiProductOperations :ivar api_policy: ApiPolicyOperations operations - :vartype api_policy: api_management_client.aio.operations.ApiPolicyOperations + :vartype api_policy: azure.mgmt.apimanagement.aio.operations.ApiPolicyOperations :ivar api_schema: ApiSchemaOperations operations - :vartype api_schema: api_management_client.aio.operations.ApiSchemaOperations + :vartype api_schema: azure.mgmt.apimanagement.aio.operations.ApiSchemaOperations :ivar api_diagnostic: ApiDiagnosticOperations operations - :vartype api_diagnostic: api_management_client.aio.operations.ApiDiagnosticOperations + :vartype api_diagnostic: azure.mgmt.apimanagement.aio.operations.ApiDiagnosticOperations :ivar api_issue: ApiIssueOperations operations - :vartype api_issue: api_management_client.aio.operations.ApiIssueOperations + :vartype api_issue: azure.mgmt.apimanagement.aio.operations.ApiIssueOperations :ivar api_issue_comment: ApiIssueCommentOperations operations - :vartype api_issue_comment: api_management_client.aio.operations.ApiIssueCommentOperations + :vartype api_issue_comment: azure.mgmt.apimanagement.aio.operations.ApiIssueCommentOperations :ivar api_issue_attachment: ApiIssueAttachmentOperations operations :vartype api_issue_attachment: - api_management_client.aio.operations.ApiIssueAttachmentOperations + azure.mgmt.apimanagement.aio.operations.ApiIssueAttachmentOperations :ivar api_tag_description: ApiTagDescriptionOperations operations - :vartype api_tag_description: api_management_client.aio.operations.ApiTagDescriptionOperations + :vartype api_tag_description: + azure.mgmt.apimanagement.aio.operations.ApiTagDescriptionOperations :ivar operation: OperationOperations operations - :vartype operation: api_management_client.aio.operations.OperationOperations + :vartype operation: azure.mgmt.apimanagement.aio.operations.OperationOperations :ivar api_export: ApiExportOperations operations - :vartype api_export: api_management_client.aio.operations.ApiExportOperations + :vartype api_export: azure.mgmt.apimanagement.aio.operations.ApiExportOperations :ivar api_version_set: ApiVersionSetOperations operations - :vartype api_version_set: api_management_client.aio.operations.ApiVersionSetOperations + :vartype api_version_set: azure.mgmt.apimanagement.aio.operations.ApiVersionSetOperations :ivar authorization_server: AuthorizationServerOperations operations :vartype authorization_server: - api_management_client.aio.operations.AuthorizationServerOperations + azure.mgmt.apimanagement.aio.operations.AuthorizationServerOperations + :ivar authorization_provider: AuthorizationProviderOperations operations + :vartype authorization_provider: + azure.mgmt.apimanagement.aio.operations.AuthorizationProviderOperations + :ivar authorization: AuthorizationOperations operations + :vartype authorization: azure.mgmt.apimanagement.aio.operations.AuthorizationOperations + :ivar authorization_login_links: AuthorizationLoginLinksOperations operations + :vartype authorization_login_links: + azure.mgmt.apimanagement.aio.operations.AuthorizationLoginLinksOperations + :ivar authorization_access_policy: AuthorizationAccessPolicyOperations operations + :vartype authorization_access_policy: + azure.mgmt.apimanagement.aio.operations.AuthorizationAccessPolicyOperations :ivar backend: BackendOperations operations - :vartype backend: api_management_client.aio.operations.BackendOperations + :vartype backend: azure.mgmt.apimanagement.aio.operations.BackendOperations :ivar cache: CacheOperations operations - :vartype cache: api_management_client.aio.operations.CacheOperations + :vartype cache: azure.mgmt.apimanagement.aio.operations.CacheOperations :ivar certificate: CertificateOperations operations - :vartype certificate: api_management_client.aio.operations.CertificateOperations + :vartype certificate: azure.mgmt.apimanagement.aio.operations.CertificateOperations :ivar content_type: ContentTypeOperations operations - :vartype content_type: api_management_client.aio.operations.ContentTypeOperations + :vartype content_type: azure.mgmt.apimanagement.aio.operations.ContentTypeOperations :ivar content_item: ContentItemOperations operations - :vartype content_item: api_management_client.aio.operations.ContentItemOperations + :vartype content_item: azure.mgmt.apimanagement.aio.operations.ContentItemOperations :ivar deleted_services: DeletedServicesOperations operations - :vartype deleted_services: api_management_client.aio.operations.DeletedServicesOperations + :vartype deleted_services: azure.mgmt.apimanagement.aio.operations.DeletedServicesOperations :ivar api_management_operations: ApiManagementOperationsOperations operations :vartype api_management_operations: - api_management_client.aio.operations.ApiManagementOperationsOperations + azure.mgmt.apimanagement.aio.operations.ApiManagementOperationsOperations :ivar api_management_service_skus: ApiManagementServiceSkusOperations operations :vartype api_management_service_skus: - api_management_client.aio.operations.ApiManagementServiceSkusOperations + azure.mgmt.apimanagement.aio.operations.ApiManagementServiceSkusOperations :ivar api_management_service: ApiManagementServiceOperations operations :vartype api_management_service: - api_management_client.aio.operations.ApiManagementServiceOperations + azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations :ivar diagnostic: DiagnosticOperations operations - :vartype diagnostic: api_management_client.aio.operations.DiagnosticOperations + :vartype diagnostic: azure.mgmt.apimanagement.aio.operations.DiagnosticOperations :ivar email_template: EmailTemplateOperations operations - :vartype email_template: api_management_client.aio.operations.EmailTemplateOperations + :vartype email_template: azure.mgmt.apimanagement.aio.operations.EmailTemplateOperations :ivar gateway: GatewayOperations operations - :vartype gateway: api_management_client.aio.operations.GatewayOperations + :vartype gateway: azure.mgmt.apimanagement.aio.operations.GatewayOperations :ivar gateway_hostname_configuration: GatewayHostnameConfigurationOperations operations :vartype gateway_hostname_configuration: - api_management_client.aio.operations.GatewayHostnameConfigurationOperations + azure.mgmt.apimanagement.aio.operations.GatewayHostnameConfigurationOperations :ivar gateway_api: GatewayApiOperations operations - :vartype gateway_api: api_management_client.aio.operations.GatewayApiOperations + :vartype gateway_api: azure.mgmt.apimanagement.aio.operations.GatewayApiOperations :ivar gateway_certificate_authority: GatewayCertificateAuthorityOperations operations :vartype gateway_certificate_authority: - api_management_client.aio.operations.GatewayCertificateAuthorityOperations + azure.mgmt.apimanagement.aio.operations.GatewayCertificateAuthorityOperations :ivar group: GroupOperations operations - :vartype group: api_management_client.aio.operations.GroupOperations + :vartype group: azure.mgmt.apimanagement.aio.operations.GroupOperations :ivar group_user: GroupUserOperations operations - :vartype group_user: api_management_client.aio.operations.GroupUserOperations + :vartype group_user: azure.mgmt.apimanagement.aio.operations.GroupUserOperations :ivar identity_provider: IdentityProviderOperations operations - :vartype identity_provider: api_management_client.aio.operations.IdentityProviderOperations + :vartype identity_provider: azure.mgmt.apimanagement.aio.operations.IdentityProviderOperations :ivar issue: IssueOperations operations - :vartype issue: api_management_client.aio.operations.IssueOperations + :vartype issue: azure.mgmt.apimanagement.aio.operations.IssueOperations :ivar logger: LoggerOperations operations - :vartype logger: api_management_client.aio.operations.LoggerOperations + :vartype logger: azure.mgmt.apimanagement.aio.operations.LoggerOperations :ivar named_value: NamedValueOperations operations - :vartype named_value: api_management_client.aio.operations.NamedValueOperations + :vartype named_value: azure.mgmt.apimanagement.aio.operations.NamedValueOperations :ivar network_status: NetworkStatusOperations operations - :vartype network_status: api_management_client.aio.operations.NetworkStatusOperations + :vartype network_status: azure.mgmt.apimanagement.aio.operations.NetworkStatusOperations :ivar notification: NotificationOperations operations - :vartype notification: api_management_client.aio.operations.NotificationOperations + :vartype notification: azure.mgmt.apimanagement.aio.operations.NotificationOperations :ivar notification_recipient_user: NotificationRecipientUserOperations operations :vartype notification_recipient_user: - api_management_client.aio.operations.NotificationRecipientUserOperations + azure.mgmt.apimanagement.aio.operations.NotificationRecipientUserOperations :ivar notification_recipient_email: NotificationRecipientEmailOperations operations :vartype notification_recipient_email: - api_management_client.aio.operations.NotificationRecipientEmailOperations + azure.mgmt.apimanagement.aio.operations.NotificationRecipientEmailOperations :ivar open_id_connect_provider: OpenIdConnectProviderOperations operations :vartype open_id_connect_provider: - api_management_client.aio.operations.OpenIdConnectProviderOperations + azure.mgmt.apimanagement.aio.operations.OpenIdConnectProviderOperations :ivar outbound_network_dependencies_endpoints: OutboundNetworkDependenciesEndpointsOperations operations :vartype outbound_network_dependencies_endpoints: - api_management_client.aio.operations.OutboundNetworkDependenciesEndpointsOperations + azure.mgmt.apimanagement.aio.operations.OutboundNetworkDependenciesEndpointsOperations :ivar policy: PolicyOperations operations - :vartype policy: api_management_client.aio.operations.PolicyOperations + :vartype policy: azure.mgmt.apimanagement.aio.operations.PolicyOperations :ivar policy_description: PolicyDescriptionOperations operations - :vartype policy_description: api_management_client.aio.operations.PolicyDescriptionOperations + :vartype policy_description: + azure.mgmt.apimanagement.aio.operations.PolicyDescriptionOperations + :ivar policy_fragment: PolicyFragmentOperations operations + :vartype policy_fragment: azure.mgmt.apimanagement.aio.operations.PolicyFragmentOperations + :ivar portal_config: PortalConfigOperations operations + :vartype portal_config: azure.mgmt.apimanagement.aio.operations.PortalConfigOperations :ivar portal_revision: PortalRevisionOperations operations - :vartype portal_revision: api_management_client.aio.operations.PortalRevisionOperations + :vartype portal_revision: azure.mgmt.apimanagement.aio.operations.PortalRevisionOperations :ivar portal_settings: PortalSettingsOperations operations - :vartype portal_settings: api_management_client.aio.operations.PortalSettingsOperations + :vartype portal_settings: azure.mgmt.apimanagement.aio.operations.PortalSettingsOperations :ivar sign_in_settings: SignInSettingsOperations operations - :vartype sign_in_settings: api_management_client.aio.operations.SignInSettingsOperations + :vartype sign_in_settings: azure.mgmt.apimanagement.aio.operations.SignInSettingsOperations :ivar sign_up_settings: SignUpSettingsOperations operations - :vartype sign_up_settings: api_management_client.aio.operations.SignUpSettingsOperations + :vartype sign_up_settings: azure.mgmt.apimanagement.aio.operations.SignUpSettingsOperations :ivar delegation_settings: DelegationSettingsOperations operations - :vartype delegation_settings: api_management_client.aio.operations.DelegationSettingsOperations + :vartype delegation_settings: + azure.mgmt.apimanagement.aio.operations.DelegationSettingsOperations :ivar private_endpoint_connection: PrivateEndpointConnectionOperations operations :vartype private_endpoint_connection: - api_management_client.aio.operations.PrivateEndpointConnectionOperations + azure.mgmt.apimanagement.aio.operations.PrivateEndpointConnectionOperations :ivar product: ProductOperations operations - :vartype product: api_management_client.aio.operations.ProductOperations + :vartype product: azure.mgmt.apimanagement.aio.operations.ProductOperations :ivar product_api: ProductApiOperations operations - :vartype product_api: api_management_client.aio.operations.ProductApiOperations + :vartype product_api: azure.mgmt.apimanagement.aio.operations.ProductApiOperations :ivar product_group: ProductGroupOperations operations - :vartype product_group: api_management_client.aio.operations.ProductGroupOperations + :vartype product_group: azure.mgmt.apimanagement.aio.operations.ProductGroupOperations :ivar product_subscriptions: ProductSubscriptionsOperations operations :vartype product_subscriptions: - api_management_client.aio.operations.ProductSubscriptionsOperations + azure.mgmt.apimanagement.aio.operations.ProductSubscriptionsOperations :ivar product_policy: ProductPolicyOperations operations - :vartype product_policy: api_management_client.aio.operations.ProductPolicyOperations + :vartype product_policy: azure.mgmt.apimanagement.aio.operations.ProductPolicyOperations :ivar quota_by_counter_keys: QuotaByCounterKeysOperations operations :vartype quota_by_counter_keys: - api_management_client.aio.operations.QuotaByCounterKeysOperations + azure.mgmt.apimanagement.aio.operations.QuotaByCounterKeysOperations :ivar quota_by_period_keys: QuotaByPeriodKeysOperations operations - :vartype quota_by_period_keys: api_management_client.aio.operations.QuotaByPeriodKeysOperations + :vartype quota_by_period_keys: + azure.mgmt.apimanagement.aio.operations.QuotaByPeriodKeysOperations :ivar region: RegionOperations operations - :vartype region: api_management_client.aio.operations.RegionOperations + :vartype region: azure.mgmt.apimanagement.aio.operations.RegionOperations :ivar reports: ReportsOperations operations - :vartype reports: api_management_client.aio.operations.ReportsOperations + :vartype reports: azure.mgmt.apimanagement.aio.operations.ReportsOperations :ivar global_schema: GlobalSchemaOperations operations - :vartype global_schema: api_management_client.aio.operations.GlobalSchemaOperations + :vartype global_schema: azure.mgmt.apimanagement.aio.operations.GlobalSchemaOperations :ivar tenant_settings: TenantSettingsOperations operations - :vartype tenant_settings: api_management_client.aio.operations.TenantSettingsOperations + :vartype tenant_settings: azure.mgmt.apimanagement.aio.operations.TenantSettingsOperations :ivar api_management_skus: ApiManagementSkusOperations operations - :vartype api_management_skus: api_management_client.aio.operations.ApiManagementSkusOperations + :vartype api_management_skus: + azure.mgmt.apimanagement.aio.operations.ApiManagementSkusOperations :ivar subscription: SubscriptionOperations operations - :vartype subscription: api_management_client.aio.operations.SubscriptionOperations + :vartype subscription: azure.mgmt.apimanagement.aio.operations.SubscriptionOperations :ivar tag_resource: TagResourceOperations operations - :vartype tag_resource: api_management_client.aio.operations.TagResourceOperations + :vartype tag_resource: azure.mgmt.apimanagement.aio.operations.TagResourceOperations :ivar tenant_access: TenantAccessOperations operations - :vartype tenant_access: api_management_client.aio.operations.TenantAccessOperations + :vartype tenant_access: azure.mgmt.apimanagement.aio.operations.TenantAccessOperations :ivar tenant_access_git: TenantAccessGitOperations operations - :vartype tenant_access_git: api_management_client.aio.operations.TenantAccessGitOperations + :vartype tenant_access_git: azure.mgmt.apimanagement.aio.operations.TenantAccessGitOperations :ivar tenant_configuration: TenantConfigurationOperations operations :vartype tenant_configuration: - api_management_client.aio.operations.TenantConfigurationOperations + azure.mgmt.apimanagement.aio.operations.TenantConfigurationOperations :ivar user: UserOperations operations - :vartype user: api_management_client.aio.operations.UserOperations + :vartype user: azure.mgmt.apimanagement.aio.operations.UserOperations :ivar user_group: UserGroupOperations operations - :vartype user_group: api_management_client.aio.operations.UserGroupOperations + :vartype user_group: azure.mgmt.apimanagement.aio.operations.UserGroupOperations :ivar user_subscription: UserSubscriptionOperations operations - :vartype user_subscription: api_management_client.aio.operations.UserSubscriptionOperations + :vartype user_subscription: azure.mgmt.apimanagement.aio.operations.UserSubscriptionOperations :ivar user_identities: UserIdentitiesOperations operations - :vartype user_identities: api_management_client.aio.operations.UserIdentitiesOperations + :vartype user_identities: azure.mgmt.apimanagement.aio.operations.UserIdentitiesOperations :ivar user_confirmation_password: UserConfirmationPasswordOperations operations :vartype user_confirmation_password: - api_management_client.aio.operations.UserConfirmationPasswordOperations + 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. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2022-04-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -217,81 +241,249 @@ def __init__( self._serialize = Serializer(client_models) 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.authorization_provider = AuthorizationProviderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.authorization = AuthorizationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.authorization_login_links = AuthorizationLoginLinksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.authorization_access_policy = AuthorizationAccessPolicyOperations( + 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.policy_fragment = PolicyFragmentOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.portal_config = PortalConfigOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.portal_revision = PortalRevisionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.portal_settings = PortalSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sign_in_settings = SignInSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sign_up_settings = SignUpSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.delegation_settings = DelegationSettingsOperations( + self._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 + ) def _send_request( 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 d049edf46f0a..092f5b0db7c3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_configuration.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class ApiManagementClientConfiguration(Configuration): +class ApiManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for ApiManagementClient. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class ApiManagementClientConfiguration(Configuration): :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 + :keyword api_version: Api Version. Default value is "2022-04-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +42,8 @@ def __init__( **kwargs: Any ) -> None: super(ApiManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +51,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-08-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-apimanagement/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_vendor.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_vendor.py new file mode 100644 index 000000000000..c987e41cb44a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_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 abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import ApiManagementClientConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import AsyncPipelineClient + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "AsyncPipelineClient" + _config: ApiManagementClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/__init__.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/__init__.py index 9f8b6482fabb..4d45f11ba059 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 @@ -24,6 +24,10 @@ from ._api_export_operations import ApiExportOperations from ._api_version_set_operations import ApiVersionSetOperations from ._authorization_server_operations import AuthorizationServerOperations +from ._authorization_provider_operations import AuthorizationProviderOperations +from ._authorization_operations import AuthorizationOperations +from ._authorization_login_links_operations import AuthorizationLoginLinksOperations +from ._authorization_access_policy_operations import AuthorizationAccessPolicyOperations from ._backend_operations import BackendOperations from ._cache_operations import CacheOperations from ._certificate_operations import CertificateOperations @@ -54,6 +58,8 @@ from ._outbound_network_dependencies_endpoints_operations import OutboundNetworkDependenciesEndpointsOperations from ._policy_operations import PolicyOperations from ._policy_description_operations import PolicyDescriptionOperations +from ._policy_fragment_operations import PolicyFragmentOperations +from ._portal_config_operations import PortalConfigOperations from ._portal_revision_operations import PortalRevisionOperations from ._portal_settings_operations import PortalSettingsOperations from ._sign_in_settings_operations import SignInSettingsOperations @@ -83,6 +89,9 @@ from ._user_identities_operations import UserIdentitiesOperations from ._user_confirmation_password_operations import UserConfirmationPasswordOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ApiOperations', 'ApiRevisionOperations', @@ -102,6 +111,10 @@ 'ApiExportOperations', 'ApiVersionSetOperations', 'AuthorizationServerOperations', + 'AuthorizationProviderOperations', + 'AuthorizationOperations', + 'AuthorizationLoginLinksOperations', + 'AuthorizationAccessPolicyOperations', 'BackendOperations', 'CacheOperations', 'CertificateOperations', @@ -132,6 +145,8 @@ 'OutboundNetworkDependenciesEndpointsOperations', 'PolicyOperations', 'PolicyDescriptionOperations', + 'PolicyFragmentOperations', + 'PortalConfigOperations', 'PortalRevisionOperations', 'PortalSettingsOperations', 'SignInSettingsOperations', @@ -161,3 +176,5 @@ 'UserIdentitiesOperations', 'UserConfirmationPasswordOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 3f8528325697..c0ddb8a75e4c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_diagnostic_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_diagnostic_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_diagnostic_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiDiagnosticOperations: - """ApiDiagnosticOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_diagnostic` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -56,7 +55,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.DiagnosticCollection"]: + ) -> AsyncIterable[_models.DiagnosticCollection]: """Lists all diagnostics of an API. :param resource_group_name: The name of the resource group. @@ -67,24 +66,30 @@ def list_by_service( :type api_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DiagnosticCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.DiagnosticCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DiagnosticCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -93,13 +98,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -108,13 +116,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +139,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -142,7 +157,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -169,11 +184,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -182,12 +202,19 @@ async def get_entity_tag( api_id=api_id, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -203,7 +230,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace_async @@ -214,7 +241,7 @@ async def get( api_id: str, diagnostic_id: str, **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _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. @@ -228,14 +255,19 @@ async def get( :type diagnostic_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticContract] request = build_get_request( @@ -244,12 +276,19 @@ async def get( api_id=api_id, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -267,7 +306,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace_async @@ -277,10 +316,10 @@ async def create_or_update( service_name: str, api_id: str, diagnostic_id: str, - parameters: "_models.DiagnosticContract", + parameters: _models.DiagnosticContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _models.DiagnosticContract: """Creates a new Diagnostic for an API or updates an existing one. :param resource_group_name: The name of the resource group. @@ -293,22 +332,26 @@ async def create_or_update( service instance. :type diagnostic_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.DiagnosticContract + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticContract] _json = self._serialize.body(parameters, 'DiagnosticContract') @@ -318,15 +361,22 @@ async def create_or_update( api_id=api_id, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -350,7 +400,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace_async @@ -361,9 +411,9 @@ async def update( api_id: str, diagnostic_id: str, if_match: str, - parameters: "_models.DiagnosticContract", + parameters: _models.DiagnosticContract, **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _models.DiagnosticContract: """Updates the details of the Diagnostic for an API specified by its identifier. :param resource_group_name: The name of the resource group. @@ -379,19 +429,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Diagnostic Update parameters. - :type parameters: ~api_management_client.models.DiagnosticContract + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticContract] _json = self._serialize.body(parameters, 'DiagnosticContract') @@ -401,15 +455,22 @@ async def update( api_id=api_id, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -427,11 +488,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -459,11 +520,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -472,13 +538,20 @@ async def delete( api_id=api_id, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -489,5 +562,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_export_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_export_operations.py index d6cc0ff9af64..f220c76bcb5e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_export_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_export_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,44 +6,42 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_export_operations import build_get_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiExportOperations: - """ApiExportOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_export` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -53,7 +52,7 @@ async def get( format: Union[str, "_models.ExportFormat"], export: Union[str, "_models.ExportApi"], **kwargs: Any - ) -> "_models.ApiExportResult": + ) -> _models.ApiExportResult: """Gets the details of the API specified by its identifier in the format specified to the Storage Blob with SAS Key valid for 5 minutes. @@ -66,19 +65,24 @@ async def get( :type api_id: str :param format: Format in which to export the Api Details to the Storage Blob with Sas Key valid for 5 minutes. - :type format: str or ~api_management_client.models.ExportFormat + :type format: str or ~azure.mgmt.apimanagement.models.ExportFormat :param export: Query parameter required to export the API details. - :type export: str or ~api_management_client.models.ExportApi + :type export: str or ~azure.mgmt.apimanagement.models.ExportApi :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiExportResult, or the result of cls(response) - :rtype: ~api_management_client.models.ApiExportResult + :rtype: ~azure.mgmt.apimanagement.models.ApiExportResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiExportResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiExportResult] request = build_get_request( @@ -86,14 +90,21 @@ async def get( service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, format=format, export=export, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -108,5 +119,5 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_attachment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_attachment_operations.py index f6d4d34929c9..d02cc43d043f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_attachment_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_attachment_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_issue_attachment_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiIssueAttachmentOperations: - """ApiIssueAttachmentOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_issue_attachment` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -57,7 +56,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.IssueAttachmentCollection"]: + ) -> AsyncIterable[_models.IssueAttachmentCollection]: """Lists all attachments for the Issue associated with the specified API. :param resource_group_name: The name of the resource group. @@ -72,24 +71,30 @@ def list_by_service( :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either IssueAttachmentCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.IssueAttachmentCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueAttachmentCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueAttachmentCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueAttachmentCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -99,13 +104,16 @@ def prepare_request(next_link=None): api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -115,13 +123,16 @@ def prepare_request(next_link=None): api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -135,7 +146,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -149,7 +164,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -181,11 +196,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -195,12 +215,19 @@ async def get_entity_tag( issue_id=issue_id, attachment_id=attachment_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +243,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}"} # type: ignore @distributed_trace_async @@ -228,7 +255,7 @@ async def get( issue_id: str, attachment_id: str, **kwargs: Any - ) -> "_models.IssueAttachmentContract": + ) -> _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. @@ -245,14 +272,19 @@ async def get( :type attachment_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: IssueAttachmentContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueAttachmentContract + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueAttachmentContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueAttachmentContract] request = build_get_request( @@ -262,12 +294,19 @@ async def get( issue_id=issue_id, attachment_id=attachment_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -285,7 +324,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}"} # type: ignore @distributed_trace_async @@ -296,10 +335,10 @@ async def create_or_update( api_id: str, issue_id: str, attachment_id: str, - parameters: "_models.IssueAttachmentContract", + parameters: _models.IssueAttachmentContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IssueAttachmentContract": + ) -> _models.IssueAttachmentContract: """Creates a new Attachment for the Issue in an API or updates an existing one. :param resource_group_name: The name of the resource group. @@ -315,22 +354,26 @@ async def create_or_update( Issue. :type attachment_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.IssueAttachmentContract + :type parameters: ~azure.mgmt.apimanagement.models.IssueAttachmentContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: IssueAttachmentContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueAttachmentContract + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueAttachmentContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueAttachmentContract] _json = self._serialize.body(parameters, 'IssueAttachmentContract') @@ -341,15 +384,22 @@ async def create_or_update( issue_id=issue_id, attachment_id=attachment_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -373,11 +423,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -409,11 +459,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -423,13 +478,20 @@ async def delete( issue_id=issue_id, attachment_id=attachment_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -440,5 +502,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_comment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_comment_operations.py index a47be54189f9..af05b08f7ebe 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_comment_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_comment_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_issue_comment_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiIssueCommentOperations: - """ApiIssueCommentOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_issue_comment` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -57,7 +56,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.IssueCommentCollection"]: + ) -> AsyncIterable[_models.IssueCommentCollection]: """Lists all comments for the Issue associated with the specified API. :param resource_group_name: The name of the resource group. @@ -72,24 +71,30 @@ def list_by_service( :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either IssueCommentCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.IssueCommentCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueCommentCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCommentCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueCommentCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -99,13 +104,16 @@ def prepare_request(next_link=None): api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -115,13 +123,16 @@ def prepare_request(next_link=None): api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -135,7 +146,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -149,7 +164,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -180,11 +195,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -194,12 +214,19 @@ async def get_entity_tag( issue_id=issue_id, comment_id=comment_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -215,7 +242,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}"} # type: ignore @distributed_trace_async @@ -227,7 +254,7 @@ async def get( issue_id: str, comment_id: str, **kwargs: Any - ) -> "_models.IssueCommentContract": + ) -> _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. @@ -243,14 +270,19 @@ async def get( :type comment_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: IssueCommentContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueCommentContract + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCommentContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueCommentContract] request = build_get_request( @@ -260,12 +292,19 @@ async def get( issue_id=issue_id, comment_id=comment_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -283,7 +322,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}"} # type: ignore @distributed_trace_async @@ -294,10 +333,10 @@ async def create_or_update( api_id: str, issue_id: str, comment_id: str, - parameters: "_models.IssueCommentContract", + parameters: _models.IssueCommentContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IssueCommentContract": + ) -> _models.IssueCommentContract: """Creates a new Comment for the Issue in an API or updates an existing one. :param resource_group_name: The name of the resource group. @@ -312,22 +351,26 @@ async def create_or_update( :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. :type comment_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.IssueCommentContract + :type parameters: ~azure.mgmt.apimanagement.models.IssueCommentContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: IssueCommentContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueCommentContract + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCommentContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueCommentContract] _json = self._serialize.body(parameters, 'IssueCommentContract') @@ -338,15 +381,22 @@ async def create_or_update( issue_id=issue_id, comment_id=comment_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -370,11 +420,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -405,11 +455,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -419,13 +474,20 @@ async def delete( issue_id=issue_id, comment_id=comment_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -436,5 +498,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_operations.py index 0f9ba2e907af..ed7da60e0263 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_issue_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiIssueOperations: - """ApiIssueOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_issue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -57,7 +56,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.IssueCollection"]: + ) -> AsyncIterable[_models.IssueCollection]: """Lists all issues associated with the specified API. :param resource_group_name: The name of the resource group. @@ -70,24 +69,30 @@ def list_by_service( functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| state | - filter | eq | |
. + filter | eq | |
. Default value is None. :type filter: str - :param expand_comments_attachments: Expand the comment attachments. + :param expand_comments_attachments: Expand the comment attachments. Default value is None. :type expand_comments_attachments: bool - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either IssueCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.IssueCollection] + :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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -96,14 +101,17 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, expand_comments_attachments=expand_comments_attachments, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -112,14 +120,17 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, expand_comments_attachments=expand_comments_attachments, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -133,7 +144,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,7 +162,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -174,11 +189,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -187,12 +207,19 @@ async def get_entity_tag( api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -208,7 +235,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # type: ignore @distributed_trace_async @@ -220,7 +247,7 @@ async def get( issue_id: str, expand_comments_attachments: Optional[bool] = None, **kwargs: Any - ) -> "_models.IssueContract": + ) -> _models.IssueContract: """Gets the details of the Issue for an API specified by its identifier. :param resource_group_name: The name of the resource group. @@ -232,18 +259,23 @@ async def get( :param issue_id: Issue identifier. Must be unique in the current API Management service instance. :type issue_id: str - :param expand_comments_attachments: Expand the comment attachments. + :param expand_comments_attachments: Expand the comment attachments. Default value is None. :type expand_comments_attachments: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: IssueContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueContract + :rtype: ~azure.mgmt.apimanagement.models.IssueContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueContract] request = build_get_request( @@ -252,13 +284,20 @@ async def get( api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, expand_comments_attachments=expand_comments_attachments, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -276,7 +315,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # type: ignore @distributed_trace_async @@ -286,10 +325,10 @@ async def create_or_update( service_name: str, api_id: str, issue_id: str, - parameters: "_models.IssueContract", + parameters: _models.IssueContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IssueContract": + ) -> _models.IssueContract: """Creates a new Issue for an API or updates an existing one. :param resource_group_name: The name of the resource group. @@ -302,22 +341,26 @@ async def create_or_update( instance. :type issue_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.IssueContract + :type parameters: ~azure.mgmt.apimanagement.models.IssueContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: IssueContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueContract + :rtype: ~azure.mgmt.apimanagement.models.IssueContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueContract] _json = self._serialize.body(parameters, 'IssueContract') @@ -327,15 +370,22 @@ async def create_or_update( api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -359,7 +409,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # type: ignore @distributed_trace_async @@ -370,9 +420,9 @@ async def update( api_id: str, issue_id: str, if_match: str, - parameters: "_models.IssueUpdateContract", + parameters: _models.IssueUpdateContract, **kwargs: Any - ) -> "_models.IssueContract": + ) -> _models.IssueContract: """Updates an existing issue for an API. :param resource_group_name: The name of the resource group. @@ -388,19 +438,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.IssueUpdateContract + :type parameters: ~azure.mgmt.apimanagement.models.IssueUpdateContract :keyword callable cls: A custom type or function that will be passed the direct response :return: IssueContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueContract + :rtype: ~azure.mgmt.apimanagement.models.IssueContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueContract] _json = self._serialize.body(parameters, 'IssueUpdateContract') @@ -410,15 +464,22 @@ async def update( api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -436,11 +497,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -468,11 +529,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -481,13 +547,20 @@ async def delete( api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -498,5 +571,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_client_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_client_operations.py index 02126185a7f2..e53578351808 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_client_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -15,31 +14,37 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request from ...operations._api_management_client_operations import build_perform_connectivity_check_async_request_initial +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApiManagementClientOperationsMixin: +class ApiManagementClientOperationsMixin(MixinABC): async def _perform_connectivity_check_async_initial( self, resource_group_name: str, service_name: str, - connectivity_check_request_params: "_models.ConnectivityCheckRequest", + connectivity_check_request_params: _models.ConnectivityCheckRequest, **kwargs: Any - ) -> Optional["_models.ConnectivityCheckResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ConnectivityCheckResponse"]] + ) -> Optional[_models.ConnectivityCheckResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ConnectivityCheckResponse]] _json = self._serialize.body(connectivity_check_request_params, 'ConnectivityCheckRequest') @@ -47,14 +52,21 @@ async def _perform_connectivity_check_async_initial( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._perform_connectivity_check_async_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -70,7 +82,7 @@ async def _perform_connectivity_check_async_initial( return deserialized - _perform_connectivity_check_async_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck'} # type: ignore + _perform_connectivity_check_async_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck"} # type: ignore @distributed_trace_async @@ -78,9 +90,9 @@ async def begin_perform_connectivity_check_async( self, resource_group_name: str, service_name: str, - connectivity_check_request_params: "_models.ConnectivityCheckRequest", + connectivity_check_request_params: _models.ConnectivityCheckRequest, **kwargs: Any - ) -> AsyncLROPoller["_models.ConnectivityCheckResponse"]: + ) -> AsyncLROPoller[_models.ConnectivityCheckResponse]: """Performs a connectivity check between the API Management service and a given destination, and returns metrics for the connection, as well as errors encountered while trying to establish it. @@ -89,7 +101,8 @@ async def begin_perform_connectivity_check_async( :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: ~api_management_client.models.ConnectivityCheckRequest + :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 @@ -101,38 +114,50 @@ async def begin_perform_connectivity_check_async( :return: An instance of AsyncLROPoller that returns either ConnectivityCheckResponse or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.ConnectivityCheckResponse] + ~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"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectivityCheckResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._perform_connectivity_check_async_initial( + raw_result = await self._perform_connectivity_check_async_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, connectivity_check_request_params=connectivity_check_request_params, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **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() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -141,7 +166,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_perform_connectivity_check_async.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck'} # type: ignore + begin_perform_connectivity_check_async.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_operations_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_operations_operations.py index 4956b9c0c9b0..b602157f4660 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_operations_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_operations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,71 +14,81 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_management_operations_operations import build_list_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiManagementOperationsOperations: - """ApiManagementOperationsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_management_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_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 :return: An iterator like instance of either OperationListResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.OperationListResult] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +102,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -107,4 +120,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.ApiManagement/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.ApiManagement/operations"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_operations.py index 7f87d5411907..3cc43f4e44d5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,51 +16,55 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request from ...operations._api_management_service_operations import build_apply_network_configuration_updates_request_initial, build_backup_request_initial, build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_get_domain_ownership_identifier_request, build_get_request, build_get_sso_token_request, build_list_by_resource_group_request, build_list_request, build_restore_request_initial, build_update_request_initial +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiManagementServiceOperations: - """ApiManagementServiceOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_management_service` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _restore_initial( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceBackupRestoreParameters", + parameters: _models.ApiManagementServiceBackupRestoreParameters, **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] _json = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') @@ -69,14 +72,21 @@ async def _restore_initial( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._restore_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -92,7 +102,7 @@ async def _restore_initial( return deserialized - _restore_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore'} # type: ignore + _restore_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore"} # type: ignore @distributed_trace_async @@ -100,9 +110,9 @@ async def begin_restore( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceBackupRestoreParameters", + parameters: _models.ApiManagementServiceBackupRestoreParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.ApiManagementServiceResource"]: + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: """Restores a backup of an API Management service created using the ApiManagementService_Backup operation on the current service. This is a long running operation and could take several minutes to complete. @@ -113,7 +123,7 @@ async def begin_restore( :type service_name: str :param parameters: Parameters supplied to the Restore API Management service from backup operation. - :type parameters: ~api_management_client.models.ApiManagementServiceBackupRestoreParameters + :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 @@ -125,38 +135,50 @@ async def begin_restore( :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.ApiManagementServiceResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._restore_initial( + raw_result = await self._restore_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -165,25 +187,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore'} # type: ignore + begin_restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore"} # type: ignore async def _backup_initial( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceBackupRestoreParameters", + parameters: _models.ApiManagementServiceBackupRestoreParameters, **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] _json = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') @@ -191,14 +216,21 @@ async def _backup_initial( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._backup_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -214,7 +246,7 @@ async def _backup_initial( return deserialized - _backup_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup'} # type: ignore + _backup_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup"} # type: ignore @distributed_trace_async @@ -222,9 +254,9 @@ async def begin_backup( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceBackupRestoreParameters", + parameters: _models.ApiManagementServiceBackupRestoreParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.ApiManagementServiceResource"]: + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: """Creates a backup of the API Management service to the given Azure Storage Account. This is long running operation and could take several minutes to complete. @@ -233,7 +265,7 @@ async def begin_backup( :param service_name: The name of the API Management service. :type service_name: str :param parameters: Parameters supplied to the ApiManagementService_Backup operation. - :type parameters: ~api_management_client.models.ApiManagementServiceBackupRestoreParameters + :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 @@ -245,38 +277,50 @@ async def begin_backup( :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.ApiManagementServiceResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._backup_initial( + raw_result = await self._backup_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -285,25 +329,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_backup.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup'} # type: ignore + begin_backup.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceResource", + parameters: _models.ApiManagementServiceResource, **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] _json = self._serialize.body(parameters, 'ApiManagementServiceResource') @@ -311,14 +358,21 @@ async def _create_or_update_initial( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -337,7 +391,7 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore @distributed_trace_async @@ -345,9 +399,9 @@ async def begin_create_or_update( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceResource", + parameters: _models.ApiManagementServiceResource, **kwargs: Any - ) -> AsyncLROPoller["_models.ApiManagementServiceResource"]: + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: """Creates or updates an API Management service. This is long running operation and could take several minutes to complete. @@ -356,7 +410,7 @@ async def begin_create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param parameters: Parameters supplied to the CreateOrUpdate API Management service operation. - :type parameters: ~api_management_client.models.ApiManagementServiceResource + :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 @@ -368,38 +422,50 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.ApiManagementServiceResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -408,25 +474,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore async def _update_initial( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceUpdateParameters", + parameters: _models.ApiManagementServiceUpdateParameters, **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] _json = self._serialize.body(parameters, 'ApiManagementServiceUpdateParameters') @@ -434,14 +503,21 @@ async def _update_initial( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -457,7 +533,7 @@ async def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore @distributed_trace_async @@ -465,9 +541,9 @@ async def begin_update( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceUpdateParameters", + parameters: _models.ApiManagementServiceUpdateParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.ApiManagementServiceResource"]: + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: """Updates an existing API Management service. :param resource_group_name: The name of the resource group. @@ -475,7 +551,7 @@ async def begin_update( :param service_name: The name of the API Management service. :type service_name: str :param parameters: Parameters supplied to the CreateOrUpdate API Management service operation. - :type parameters: ~api_management_client.models.ApiManagementServiceUpdateParameters + :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 @@ -487,38 +563,50 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.ApiManagementServiceResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -527,10 +615,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore @distributed_trace_async async def get( @@ -538,7 +625,7 @@ async def get( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.ApiManagementServiceResource": + ) -> _models.ApiManagementServiceResource: """Gets an API Management service resource description. :param resource_group_name: The name of the resource group. @@ -547,26 +634,38 @@ async def get( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiManagementServiceResource, or the result of cls(response) - :rtype: ~api_management_client.models.ApiManagementServiceResource + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceResource] request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -581,7 +680,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore async def _delete_initial( @@ -589,24 +688,36 @@ async def _delete_initial( resource_group_name: str, service_name: str, **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] request = build_delete_request_initial( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -622,7 +733,7 @@ async def _delete_initial( return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore @distributed_trace_async @@ -631,7 +742,7 @@ async def begin_delete( resource_group_name: str, service_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.ApiManagementServiceResource"]: + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: """Deletes an existing API Management service. :param resource_group_name: The name of the resource group. @@ -649,35 +760,47 @@ async def begin_delete( :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.ApiManagementServiceResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -686,17 +809,16 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ApiManagementServiceListResult"]: + ) -> AsyncIterable[_models.ApiManagementServiceListResult]: """List all API Management services within a resource group. :param resource_group_name: The name of the resource group. @@ -705,34 +827,45 @@ def list_by_resource_group( :return: An iterator like instance of either ApiManagementServiceListResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ApiManagementServiceListResult] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -746,7 +879,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -760,45 +897,56 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ApiManagementServiceListResult"]: + ) -> AsyncIterable[_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.async_paging.AsyncItemPaged[~api_management_client.models.ApiManagementServiceListResult] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -812,7 +960,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -826,7 +978,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service"} # type: ignore @distributed_trace_async async def get_sso_token( @@ -834,7 +986,7 @@ async def get_sso_token( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.ApiManagementServiceGetSsoTokenResult": + ) -> _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. @@ -843,26 +995,38 @@ async def get_sso_token( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiManagementServiceGetSsoTokenResult, or the result of cls(response) - :rtype: ~api_management_client.models.ApiManagementServiceGetSsoTokenResult + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetSsoTokenResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceGetSsoTokenResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceGetSsoTokenResult] request = build_get_sso_token_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_sso_token.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -877,45 +1041,56 @@ async def get_sso_token( return deserialized - get_sso_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken'} # type: ignore + get_sso_token.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken"} # type: ignore @distributed_trace_async async def check_name_availability( self, - parameters: "_models.ApiManagementServiceCheckNameAvailabilityParameters", + parameters: _models.ApiManagementServiceCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.ApiManagementServiceNameAvailabilityResult": + ) -> _models.ApiManagementServiceNameAvailabilityResult: """Checks availability and correctness of a name for an API Management service. :param parameters: Parameters supplied to the CheckNameAvailability operation. :type parameters: - ~api_management_client.models.ApiManagementServiceCheckNameAvailabilityParameters + ~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: ~api_management_client.models.ApiManagementServiceNameAvailabilityResult + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceNameAvailabilityResult] _json = self._serialize.body(parameters, 'ApiManagementServiceCheckNameAvailabilityParameters') request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.check_name_availability.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -930,36 +1105,48 @@ async def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability"} # type: ignore @distributed_trace_async async def get_domain_ownership_identifier( self, **kwargs: Any - ) -> "_models.ApiManagementServiceGetDomainOwnershipIdentifierResult": + ) -> _models.ApiManagementServiceGetDomainOwnershipIdentifierResult: """Get the custom domain ownership identifier for an API Management service. :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiManagementServiceGetDomainOwnershipIdentifierResult, or the result of cls(response) - :rtype: ~api_management_client.models.ApiManagementServiceGetDomainOwnershipIdentifierResult + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetDomainOwnershipIdentifierResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceGetDomainOwnershipIdentifierResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceGetDomainOwnershipIdentifierResult] request = build_get_domain_ownership_identifier_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_domain_ownership_identifier.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -974,23 +1161,27 @@ async def get_domain_ownership_identifier( return deserialized - get_domain_ownership_identifier.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier'} # type: ignore + get_domain_ownership_identifier.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier"} # type: ignore async def _apply_network_configuration_updates_initial( self, resource_group_name: str, service_name: str, - parameters: Optional["_models.ApiManagementServiceApplyNetworkConfigurationParameters"] = None, + parameters: Optional[_models.ApiManagementServiceApplyNetworkConfigurationParameters] = None, **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] if parameters is not None: _json = self._serialize.body(parameters, 'ApiManagementServiceApplyNetworkConfigurationParameters') @@ -1001,14 +1192,21 @@ async def _apply_network_configuration_updates_initial( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._apply_network_configuration_updates_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1024,7 +1222,7 @@ async def _apply_network_configuration_updates_initial( return deserialized - _apply_network_configuration_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates'} # type: ignore + _apply_network_configuration_updates_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates"} # type: ignore @distributed_trace_async @@ -1032,9 +1230,9 @@ async def begin_apply_network_configuration_updates( self, resource_group_name: str, service_name: str, - parameters: Optional["_models.ApiManagementServiceApplyNetworkConfigurationParameters"] = None, + parameters: Optional[_models.ApiManagementServiceApplyNetworkConfigurationParameters] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.ApiManagementServiceResource"]: + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: """Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated DNS changes. @@ -1044,9 +1242,9 @@ async def begin_apply_network_configuration_updates( :type service_name: str :param parameters: Parameters supplied to the Apply Network Configuration operation. If the parameters are empty, all the regions in which the Api Management service is deployed will be - updated sequentially without incurring downtime in the region. + updated sequentially without incurring downtime in the region. Default value is None. :type parameters: - ~api_management_client.models.ApiManagementServiceApplyNetworkConfigurationParameters + ~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 @@ -1058,38 +1256,50 @@ async def begin_apply_network_configuration_updates( :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.ApiManagementServiceResource] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._apply_network_configuration_updates_initial( + raw_result = await self._apply_network_configuration_updates_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1098,7 +1308,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_apply_network_configuration_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates'} # type: ignore + begin_apply_network_configuration_updates.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_skus_operations.py index ffa3b8210fe2..6a90a15df53d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_skus_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,36 +14,35 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_management_service_skus_operations import build_list_available_service_skus_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiManagementServiceSkusOperations: - """ApiManagementServiceSkusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_management_service_skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_available_service_skus( @@ -52,7 +50,7 @@ def list_available_service_skus( resource_group_name: str, service_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ResourceSkuResults"]: + ) -> AsyncIterable[_models.ResourceSkuResults]: """Gets available SKUs for API Management service. Gets all available SKU for a given API Management service. @@ -64,14 +62,19 @@ def list_available_service_skus( :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[~api_management_client.models.ResourceSkuResults] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ResourceSkuResults] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuResults"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceSkuResults] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,10 +82,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_available_service_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -90,10 +96,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -107,7 +116,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,4 +134,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_available_service_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus'} # type: ignore + list_available_service_skus.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_skus_operations.py index b01df3ab7be6..b199c70a6b31 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_skus_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,74 +14,84 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_management_skus_operations import build_list_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiManagementSkusOperations: - """ApiManagementSkusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_management_skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ApiManagementSkusResult"]: + ) -> AsyncIterable[_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) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ApiManagementSkusResult] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementSkusResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementSkusResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +105,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,4 +123,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/skus"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_operations.py index 395d99437277..49e22d65e80f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_operation_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_api_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiOperationOperations: - """ApiOperationOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_operation` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_api( @@ -57,7 +56,7 @@ def list_by_api( skip: Optional[int] = None, tags: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.OperationCollection"]: + ) -> AsyncIterable[_models.OperationCollection]: """Lists a collection of the operations for the specified API. :param resource_group_name: The name of the resource group. @@ -74,25 +73,30 @@ def list_by_api( |
| method | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| urlTemplate | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
. + startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param tags: Include tags in the response. + :param tags: Include tags in the response. Default value is None. :type tags: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.OperationCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.OperationCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -101,14 +105,17 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, tags=tags, template_url=self.list_by_api.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -117,14 +124,17 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, tags=tags, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -138,7 +148,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -152,7 +166,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations'} # type: ignore + list_by_api.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -180,11 +194,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -193,12 +212,19 @@ async def get_entity_tag( api_id=api_id, operation_id=operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,7 +240,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # type: ignore @distributed_trace_async @@ -225,7 +251,7 @@ async def get( api_id: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationContract": + ) -> _models.OperationContract: """Gets the details of the API Operation specified by its identifier. :param resource_group_name: The name of the resource group. @@ -240,14 +266,19 @@ async def get( :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationContract, or the result of cls(response) - :rtype: ~api_management_client.models.OperationContract + :rtype: ~azure.mgmt.apimanagement.models.OperationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationContract] request = build_get_request( @@ -256,12 +287,19 @@ async def get( api_id=api_id, operation_id=operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -279,7 +317,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # type: ignore @distributed_trace_async @@ -289,10 +327,10 @@ async def create_or_update( service_name: str, api_id: str, operation_id: str, - parameters: "_models.OperationContract", + parameters: _models.OperationContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.OperationContract": + ) -> _models.OperationContract: """Creates a new operation in the API or updates an existing one. :param resource_group_name: The name of the resource group. @@ -306,22 +344,26 @@ async def create_or_update( Management service instance. :type operation_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.OperationContract + :type parameters: ~azure.mgmt.apimanagement.models.OperationContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationContract, or the result of cls(response) - :rtype: ~api_management_client.models.OperationContract + :rtype: ~azure.mgmt.apimanagement.models.OperationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationContract] _json = self._serialize.body(parameters, 'OperationContract') @@ -331,15 +373,22 @@ async def create_or_update( api_id=api_id, operation_id=operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -363,7 +412,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # type: ignore @distributed_trace_async @@ -374,9 +423,9 @@ async def update( api_id: str, operation_id: str, if_match: str, - parameters: "_models.OperationUpdateContract", + parameters: _models.OperationUpdateContract, **kwargs: Any - ) -> "_models.OperationContract": + ) -> _models.OperationContract: """Updates the details of the operation in the API specified by its identifier. :param resource_group_name: The name of the resource group. @@ -393,19 +442,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: API Operation Update parameters. - :type parameters: ~api_management_client.models.OperationUpdateContract + :type parameters: ~azure.mgmt.apimanagement.models.OperationUpdateContract :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationContract, or the result of cls(response) - :rtype: ~api_management_client.models.OperationContract + :rtype: ~azure.mgmt.apimanagement.models.OperationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationContract] _json = self._serialize.body(parameters, 'OperationUpdateContract') @@ -415,15 +468,22 @@ async def update( api_id=api_id, operation_id=operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -441,11 +501,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -474,11 +534,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -487,13 +552,20 @@ async def delete( api_id=api_id, operation_id=operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -504,5 +576,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_policy_operations.py index 7e6412805954..b466091ce412 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_policy_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,44 +6,42 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_operation_policy_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_operation_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiOperationPolicyOperations: - """ApiOperationPolicyOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_operation_policy` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_operation( @@ -52,7 +51,7 @@ async def list_by_operation( api_id: str, operation_id: str, **kwargs: Any - ) -> "_models.PolicyCollection": + ) -> _models.PolicyCollection: """Get the list of policy configuration at the API Operation level. :param resource_group_name: The name of the resource group. @@ -67,14 +66,19 @@ async def list_by_operation( :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyCollection + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyCollection] request = build_list_by_operation_request( @@ -83,12 +87,19 @@ async def list_by_operation( api_id=api_id, operation_id=operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_operation.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,7 +114,7 @@ async def list_by_operation( return deserialized - list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies'} # type: ignore + list_by_operation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies"} # type: ignore @distributed_trace_async @@ -129,17 +140,22 @@ async def get_entity_tag( Management service instance. :type operation_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: bool, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -149,12 +165,19 @@ async def get_entity_tag( operation_id=operation_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -170,7 +193,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}"} # type: ignore @distributed_trace_async @@ -183,7 +206,7 @@ async def get( policy_id: Union[str, "_models.PolicyIdName"], format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Get the policy configuration at the API Operation level. :param resource_group_name: The name of the resource group. @@ -197,19 +220,24 @@ async def get( Management service instance. :type operation_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param format: Policy Export Format. - :type format: str or ~api_management_client.models.PolicyExportFormat + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. Default value is "xml". + :type format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyContract] request = build_get_request( @@ -219,13 +247,20 @@ async def get( operation_id=operation_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, format=format, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -243,7 +278,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}"} # type: ignore @distributed_trace_async @@ -254,10 +289,10 @@ async def create_or_update( api_id: str, operation_id: str, policy_id: Union[str, "_models.PolicyIdName"], - parameters: "_models.PolicyContract", + parameters: _models.PolicyContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Creates or updates policy configuration for the API Operation level. :param resource_group_name: The name of the resource group. @@ -271,24 +306,28 @@ async def create_or_update( Management service instance. :type operation_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :param parameters: The policy contents to apply. - :type parameters: ~api_management_client.models.PolicyContract + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyContract] _json = self._serialize.body(parameters, 'PolicyContract') @@ -299,15 +338,22 @@ async def create_or_update( operation_id=operation_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -331,11 +377,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -358,7 +404,7 @@ async def delete( Management service instance. :type operation_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str @@ -367,11 +413,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -381,13 +432,20 @@ async def delete( operation_id=operation_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -398,5 +456,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operations.py index 5ea1c9ae2f80..66e12ff52f72 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,36 +16,36 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request from ...operations._api_operations import build_create_or_update_request_initial, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_list_by_tags_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiOperations: - """ApiOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -59,7 +58,7 @@ def list_by_service( tags: Optional[str] = None, expand_api_version_set: Optional[bool] = None, **kwargs: Any - ) -> AsyncIterable["_models.ApiCollection"]: + ) -> AsyncIterable[_models.ApiCollection]: """Lists all APIs of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -73,26 +72,32 @@ def list_by_service( |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| serviceUrl | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| isCurrent | filter | eq, ne | |
. + startswith, endswith |
| isCurrent | filter | eq, ne | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param tags: Include tags in the response. + :param tags: Include tags in the response. Default value is None. :type tags: str - :param expand_api_version_set: Include full ApiVersionSet resource in response. + :param expand_api_version_set: Include full ApiVersionSet resource in response. Default value + is None. :type expand_api_version_set: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ApiCollection] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -100,15 +105,18 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, tags=tags, expand_api_version_set=expand_api_version_set, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -116,15 +124,18 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, tags=tags, expand_api_version_set=expand_api_version_set, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -138,7 +149,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -152,7 +167,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -176,11 +191,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -188,12 +208,19 @@ async def get_entity_tag( service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,7 +236,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore @distributed_trace_async @@ -219,7 +246,7 @@ async def get( service_name: str, api_id: str, **kwargs: Any - ) -> "_models.ApiContract": + ) -> _models.ApiContract: """Gets the details of the API specified by its identifier. :param resource_group_name: The name of the resource group. @@ -231,14 +258,19 @@ async def get( :type api_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiContract + :rtype: ~azure.mgmt.apimanagement.models.ApiContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiContract] request = build_get_request( @@ -246,12 +278,19 @@ async def get( service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -269,7 +308,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore async def _create_or_update_initial( @@ -277,17 +316,21 @@ async def _create_or_update_initial( resource_group_name: str, service_name: str, api_id: str, - parameters: "_models.ApiCreateOrUpdateParameter", + parameters: _models.ApiCreateOrUpdateParameter, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.ApiContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiContract"]] + ) -> Optional[_models.ApiContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApiContract]] _json = self._serialize.body(parameters, 'ApiCreateOrUpdateParameter') @@ -296,15 +339,22 @@ async def _create_or_update_initial( service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -328,7 +378,7 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore @distributed_trace_async @@ -337,10 +387,10 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, api_id: str, - parameters: "_models.ApiCreateOrUpdateParameter", + parameters: _models.ApiCreateOrUpdateParameter, if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.ApiContract"]: + ) -> AsyncLROPoller[_models.ApiContract]: """Creates new or updates existing specified API of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -351,9 +401,9 @@ async def begin_create_or_update( instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.ApiCreateOrUpdateParameter + :type parameters: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdateParameter :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -365,26 +415,33 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ApiContract or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~api_management_client.models.ApiContract] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiContract] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiContract] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, api_id=api_id, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -400,8 +457,14 @@ def get_long_running_output(pipeline_response): 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() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -410,10 +473,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + 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( @@ -422,9 +484,9 @@ async def update( service_name: str, api_id: str, if_match: str, - parameters: "_models.ApiUpdateContract", + parameters: _models.ApiUpdateContract, **kwargs: Any - ) -> "_models.ApiContract": + ) -> _models.ApiContract: """Updates the specified API of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -438,19 +500,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: API Update Contract parameters. - :type parameters: ~api_management_client.models.ApiUpdateContract + :type parameters: ~azure.mgmt.apimanagement.models.ApiUpdateContract :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiContract + :rtype: ~azure.mgmt.apimanagement.models.ApiContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiContract] _json = self._serialize.body(parameters, 'ApiUpdateContract') @@ -459,15 +525,22 @@ async def update( service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -485,11 +558,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -510,18 +583,23 @@ async def delete( :param if_match: ETag of 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 - :param delete_revisions: Delete all revisions of the Api. + :param delete_revisions: Delete all revisions of the Api. Default value is None. :type delete_revisions: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -529,14 +607,21 @@ async def delete( service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, delete_revisions=delete_revisions, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -547,7 +632,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore @distributed_trace @@ -560,7 +645,7 @@ def list_by_tags( skip: Optional[int] = None, include_not_tagged_apis: Optional[bool] = None, **kwargs: Any - ) -> AsyncIterable["_models.TagResourceCollection"]: + ) -> AsyncIterable[_models.TagResourceCollection]: """Lists a collection of apis associated with tags. :param resource_group_name: The name of the resource group. @@ -575,26 +660,32 @@ def list_by_tags( endswith |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| serviceUrl | filter | ge, le, eq, ne, gt, lt | substringof, - contains, startswith, endswith |
| isCurrent | filter | eq | |
. + contains, startswith, endswith |
| isCurrent | filter | eq | |
. Default value is + None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param include_not_tagged_apis: Include not tagged APIs. + :param include_not_tagged_apis: Include not tagged APIs. Default value is None. :type include_not_tagged_apis: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagResourceCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TagResourceCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagResourceCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -602,14 +693,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, include_not_tagged_apis=include_not_tagged_apis, template_url=self.list_by_tags.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -617,14 +711,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, include_not_tagged_apis=include_not_tagged_apis, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -638,7 +735,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -652,4 +753,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apisByTags'} # type: ignore + list_by_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apisByTags"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_policy_operations.py index 7468a5351c07..80e986c145e2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_policy_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,44 +6,42 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_policy_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_api_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiPolicyOperations: - """ApiPolicyOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_policy` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_api( @@ -51,7 +50,7 @@ async def list_by_api( service_name: str, api_id: str, **kwargs: Any - ) -> "_models.PolicyCollection": + ) -> _models.PolicyCollection: """Get the policy configuration at the API level. :param resource_group_name: The name of the resource group. @@ -63,14 +62,19 @@ async def list_by_api( :type api_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyCollection + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyCollection] request = build_list_by_api_request( @@ -78,12 +82,19 @@ async def list_by_api( service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_api.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -98,7 +109,7 @@ async def list_by_api( return deserialized - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies'} # type: ignore + list_by_api.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies"} # type: ignore @distributed_trace_async @@ -120,17 +131,22 @@ async def get_entity_tag( instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: bool, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -139,12 +155,19 @@ async def get_entity_tag( api_id=api_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -160,7 +183,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}"} # type: ignore @distributed_trace_async @@ -172,7 +195,7 @@ async def get( policy_id: Union[str, "_models.PolicyIdName"], format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Get the policy configuration at the API level. :param resource_group_name: The name of the resource group. @@ -183,19 +206,24 @@ async def get( instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param format: Policy Export Format. - :type format: str or ~api_management_client.models.PolicyExportFormat + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. Default value is "xml". + :type format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyContract] request = build_get_request( @@ -204,13 +232,20 @@ async def get( api_id=api_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, format=format, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 200]: @@ -234,7 +269,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}"} # type: ignore @distributed_trace_async @@ -244,10 +279,10 @@ async def create_or_update( service_name: str, api_id: str, policy_id: Union[str, "_models.PolicyIdName"], - parameters: "_models.PolicyContract", + parameters: _models.PolicyContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Creates or updates policy configuration for the API. :param resource_group_name: The name of the resource group. @@ -258,24 +293,28 @@ async def create_or_update( instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :param parameters: The policy contents to apply. - :type parameters: ~api_management_client.models.PolicyContract + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyContract] _json = self._serialize.body(parameters, 'PolicyContract') @@ -285,15 +324,22 @@ async def create_or_update( api_id=api_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -317,11 +363,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -340,7 +386,7 @@ async def delete( instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str @@ -349,11 +395,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -362,13 +413,20 @@ async def delete( api_id=api_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -379,5 +437,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_product_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_product_operations.py index 4115220ddd94..20e1e4a650fe 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_product_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_product_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,36 +14,35 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_product_operations import build_list_by_apis_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiProductOperations: - """ApiProductOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_product` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_apis( @@ -56,7 +54,7 @@ def list_by_apis( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ProductCollection"]: + ) -> AsyncIterable[_models.ProductCollection]: """Lists all Products, which the API is part of. :param resource_group_name: The name of the resource group. @@ -67,23 +65,29 @@ def list_by_apis( :type api_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| displayName - | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProductCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ProductCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProductCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -92,13 +96,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_apis.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -107,13 +114,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -127,7 +137,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,4 +155,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_apis.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/products'} # type: ignore + list_by_apis.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/products"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_release_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_release_operations.py index ee7535134d3f..87d512f40cb7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_release_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_release_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_release_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiReleaseOperations: - """ApiReleaseOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_release` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -56,7 +55,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ApiReleaseCollection"]: + ) -> AsyncIterable[_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. @@ -69,24 +68,30 @@ def list_by_service( :type api_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| notes | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiReleaseCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ApiReleaseCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiReleaseCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiReleaseCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiReleaseCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -95,13 +100,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -110,13 +118,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -130,7 +141,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -144,7 +159,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -171,11 +186,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -184,12 +204,19 @@ async def get_entity_tag( api_id=api_id, release_id=release_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -205,7 +232,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # type: ignore @distributed_trace_async @@ -216,7 +243,7 @@ async def get( api_id: str, release_id: str, **kwargs: Any - ) -> "_models.ApiReleaseContract": + ) -> _models.ApiReleaseContract: """Returns the details of an API release. :param resource_group_name: The name of the resource group. @@ -230,14 +257,19 @@ async def get( :type release_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiReleaseContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiReleaseContract + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiReleaseContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiReleaseContract] request = build_get_request( @@ -246,12 +278,19 @@ async def get( api_id=api_id, release_id=release_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -269,7 +308,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # type: ignore @distributed_trace_async @@ -279,10 +318,10 @@ async def create_or_update( service_name: str, api_id: str, release_id: str, - parameters: "_models.ApiReleaseContract", + parameters: _models.ApiReleaseContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ApiReleaseContract": + ) -> _models.ApiReleaseContract: """Creates a new Release for the API. :param resource_group_name: The name of the resource group. @@ -295,22 +334,26 @@ async def create_or_update( Management service instance. :type release_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.ApiReleaseContract + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiReleaseContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiReleaseContract + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiReleaseContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiReleaseContract] _json = self._serialize.body(parameters, 'ApiReleaseContract') @@ -320,15 +363,22 @@ async def create_or_update( api_id=api_id, release_id=release_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -352,7 +402,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # type: ignore @distributed_trace_async @@ -363,9 +413,9 @@ async def update( api_id: str, release_id: str, if_match: str, - parameters: "_models.ApiReleaseContract", + parameters: _models.ApiReleaseContract, **kwargs: Any - ) -> "_models.ApiReleaseContract": + ) -> _models.ApiReleaseContract: """Updates the details of the release of the API specified by its identifier. :param resource_group_name: The name of the resource group. @@ -381,19 +431,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: API Release Update parameters. - :type parameters: ~api_management_client.models.ApiReleaseContract + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiReleaseContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiReleaseContract + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiReleaseContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiReleaseContract] _json = self._serialize.body(parameters, 'ApiReleaseContract') @@ -403,15 +457,22 @@ async def update( api_id=api_id, release_id=release_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -429,11 +490,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -461,11 +522,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -474,13 +540,20 @@ async def delete( api_id=api_id, release_id=release_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -491,5 +564,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_revision_operations.py index 4dd25937a47b..5afabb12fafd 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_revision_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_revision_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,36 +14,35 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_revision_operations import build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiRevisionOperations: - """ApiRevisionOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_revision` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -56,7 +54,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ApiRevisionCollection"]: + ) -> AsyncIterable[_models.ApiRevisionCollection]: """Lists all revisions of an API. :param resource_group_name: The name of the resource group. @@ -67,24 +65,30 @@ def list_by_service( :type api_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| apiRevision - | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiRevisionCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ApiRevisionCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiRevisionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiRevisionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiRevisionCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -93,13 +97,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -108,13 +115,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +138,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -142,4 +156,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/revisions'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/revisions"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_schema_operations.py index 6f7c5b8ddc6b..cf91a71677df 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_schema_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_schema_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,36 +16,36 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request from ...operations._api_schema_operations import build_create_or_update_request_initial, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_api_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiSchemaOperations: - """ApiSchemaOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_schema` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_api( @@ -58,7 +57,7 @@ def list_by_api( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.SchemaCollection"]: + ) -> AsyncIterable[_models.SchemaCollection]: """Get the schema configuration at the API level. :param resource_group_name: The name of the resource group. @@ -70,22 +69,29 @@ def list_by_api( :type api_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| contentType - | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SchemaCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.SchemaCollection] + :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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SchemaCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -94,13 +100,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_api.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -109,13 +118,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,7 +141,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -143,7 +159,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas'} # type: ignore + list_by_api.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -171,11 +187,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -184,12 +205,19 @@ async def get_entity_tag( api_id=api_id, schema_id=schema_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -205,7 +233,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # type: ignore @distributed_trace_async @@ -216,7 +244,7 @@ async def get( api_id: str, schema_id: str, **kwargs: Any - ) -> "_models.SchemaContract": + ) -> _models.SchemaContract: """Get the schema configuration at the API level. :param resource_group_name: The name of the resource group. @@ -231,14 +259,19 @@ async def get( :type schema_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SchemaContract, or the result of cls(response) - :rtype: ~api_management_client.models.SchemaContract + :rtype: ~azure.mgmt.apimanagement.models.SchemaContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SchemaContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SchemaContract] request = build_get_request( @@ -247,12 +280,19 @@ async def get( api_id=api_id, schema_id=schema_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -270,7 +310,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # type: ignore async def _create_or_update_initial( @@ -279,17 +319,21 @@ async def _create_or_update_initial( service_name: str, api_id: str, schema_id: str, - parameters: "_models.SchemaContract", + parameters: _models.SchemaContract, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.SchemaContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SchemaContract"]] + ) -> Optional[_models.SchemaContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SchemaContract]] _json = self._serialize.body(parameters, 'SchemaContract') @@ -299,15 +343,22 @@ async def _create_or_update_initial( api_id=api_id, schema_id=schema_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -331,7 +382,7 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # type: ignore @distributed_trace_async @@ -341,10 +392,10 @@ async def begin_create_or_update( service_name: str, api_id: str, schema_id: str, - parameters: "_models.SchemaContract", + parameters: _models.SchemaContract, if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.SchemaContract"]: + ) -> AsyncLROPoller[_models.SchemaContract]: """Creates or updates schema configuration for the API. :param resource_group_name: The name of the resource group. @@ -358,9 +409,9 @@ async def begin_create_or_update( instance. :type schema_id: str :param parameters: The schema contents to apply. - :type parameters: ~api_management_client.models.SchemaContract + :type parameters: ~azure.mgmt.apimanagement.models.SchemaContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -372,27 +423,34 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either SchemaContract or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~api_management_client.models.SchemaContract] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.SchemaContract] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SchemaContract"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SchemaContract] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, api_id=api_id, schema_id=schema_id, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -408,8 +466,14 @@ def get_long_running_output(pipeline_response): 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() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -418,13 +482,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -449,18 +512,24 @@ async def delete( :param if_match: ETag of 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 - :param force: If true removes all references to the schema before deleting it. + :param force: If true removes all references to the schema before deleting it. Default value is + None. :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -469,14 +538,21 @@ async def delete( api_id=api_id, schema_id=schema_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, force=force, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -487,5 +563,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_tag_description_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_tag_description_operations.py index 9131ad1cfb64..be4a538a7801 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_tag_description_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_tag_description_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_tag_description_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiTagDescriptionOperations: - """ApiTagDescriptionOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_tag_description` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -56,7 +55,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.TagDescriptionCollection"]: + ) -> AsyncIterable[_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. @@ -70,24 +69,30 @@ def list_by_service( :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagDescriptionCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TagDescriptionCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagDescriptionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDescriptionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagDescriptionCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -96,13 +101,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -111,13 +119,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -131,7 +142,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -145,7 +160,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -173,11 +188,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -186,12 +206,19 @@ async def get_entity_tag( api_id=api_id, tag_description_id=tag_description_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -207,7 +234,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}"} # type: ignore @distributed_trace_async @@ -218,7 +245,7 @@ async def get( api_id: str, tag_description_id: str, **kwargs: Any - ) -> "_models.TagDescriptionContract": + ) -> _models.TagDescriptionContract: """Get Tag description in scope of API. :param resource_group_name: The name of the resource group. @@ -233,14 +260,19 @@ async def get( :type tag_description_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagDescriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagDescriptionContract + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDescriptionContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagDescriptionContract] request = build_get_request( @@ -249,12 +281,19 @@ async def get( api_id=api_id, tag_description_id=tag_description_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -272,7 +311,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}"} # type: ignore @distributed_trace_async @@ -282,10 +321,10 @@ async def create_or_update( service_name: str, api_id: str, tag_description_id: str, - parameters: "_models.TagDescriptionCreateParameters", + parameters: _models.TagDescriptionCreateParameters, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.TagDescriptionContract": + ) -> _models.TagDescriptionContract: """Create/Update tag description in scope of the Api. :param resource_group_name: The name of the resource group. @@ -299,22 +338,26 @@ async def create_or_update( API/Tag association. Based on API and Tag names. :type tag_description_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.TagDescriptionCreateParameters + :type parameters: ~azure.mgmt.apimanagement.models.TagDescriptionCreateParameters :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagDescriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagDescriptionContract + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDescriptionContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagDescriptionContract] _json = self._serialize.body(parameters, 'TagDescriptionCreateParameters') @@ -324,15 +367,22 @@ async def create_or_update( api_id=api_id, tag_description_id=tag_description_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -356,11 +406,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -389,11 +439,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -402,13 +457,20 @@ async def delete( api_id=api_id, tag_description_id=tag_description_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -419,5 +481,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_version_set_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_version_set_operations.py index 90112d0b71c8..a60545c153e7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_version_set_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_version_set_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._api_version_set_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApiVersionSetOperations: - """ApiVersionSetOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_version_set` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -55,7 +54,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ApiVersionSetCollection"]: + ) -> AsyncIterable[_models.ApiVersionSetCollection]: """Lists a collection of API Version Sets in the specified service instance. :param resource_group_name: The name of the resource group. @@ -63,24 +62,30 @@ def list_by_service( :param service_name: The name of the API Management service. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
. + functions |
|-------------|-------------|-------------|-------------|
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiVersionSetCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ApiVersionSetCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiVersionSetCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiVersionSetCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiVersionSetCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -88,13 +93,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -102,13 +110,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -122,7 +133,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -136,7 +151,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -160,11 +175,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -172,12 +192,19 @@ async def get_entity_tag( service_name=service_name, version_set_id=version_set_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -193,7 +220,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # type: ignore @distributed_trace_async @@ -203,7 +230,7 @@ async def get( service_name: str, version_set_id: str, **kwargs: Any - ) -> "_models.ApiVersionSetContract": + ) -> _models.ApiVersionSetContract: """Gets the details of the Api Version Set specified by its identifier. :param resource_group_name: The name of the resource group. @@ -215,14 +242,19 @@ async def get( :type version_set_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiVersionSetContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiVersionSetContract + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiVersionSetContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiVersionSetContract] request = build_get_request( @@ -230,12 +262,19 @@ async def get( service_name=service_name, version_set_id=version_set_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -253,7 +292,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # type: ignore @distributed_trace_async @@ -262,10 +301,10 @@ async def create_or_update( resource_group_name: str, service_name: str, version_set_id: str, - parameters: "_models.ApiVersionSetContract", + parameters: _models.ApiVersionSetContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ApiVersionSetContract": + ) -> _models.ApiVersionSetContract: """Creates or Updates a Api Version Set. :param resource_group_name: The name of the resource group. @@ -276,22 +315,26 @@ async def create_or_update( service instance. :type version_set_id: str :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.ApiVersionSetContract + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiVersionSetContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiVersionSetContract + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiVersionSetContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiVersionSetContract] _json = self._serialize.body(parameters, 'ApiVersionSetContract') @@ -300,15 +343,22 @@ async def create_or_update( service_name=service_name, version_set_id=version_set_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -332,7 +382,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # type: ignore @distributed_trace_async @@ -342,9 +392,9 @@ async def update( service_name: str, version_set_id: str, if_match: str, - parameters: "_models.ApiVersionSetUpdateParameters", + parameters: _models.ApiVersionSetUpdateParameters, **kwargs: Any - ) -> "_models.ApiVersionSetContract": + ) -> _models.ApiVersionSetContract: """Updates the details of the Api VersionSet specified by its identifier. :param resource_group_name: The name of the resource group. @@ -358,19 +408,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.ApiVersionSetUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiVersionSetContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiVersionSetContract + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiVersionSetContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiVersionSetContract] _json = self._serialize.body(parameters, 'ApiVersionSetUpdateParameters') @@ -379,15 +433,22 @@ async def update( service_name=service_name, version_set_id=version_set_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,11 +466,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -434,11 +495,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -446,13 +512,20 @@ async def delete( service_name=service_name, version_set_id=version_set_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -463,5 +536,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_access_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_access_policy_operations.py new file mode 100644 index 000000000000..7ba37dc932d7 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_access_policy_operations.py @@ -0,0 +1,413 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +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.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._authorization_access_policy_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_authorization_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AuthorizationAccessPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`authorization_access_policy` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_authorization( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AuthorizationAccessPolicyCollection]: + """Lists a collection of authorization access policy defined within a authorization. + + :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 authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. + :type authorization_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AuthorizationAccessPolicyCollection or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationAccessPolicyCollection] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_authorization_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + top=top, + skip=skip, + template_url=self.list_by_authorization.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_authorization_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + top=top, + skip=skip, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AuthorizationAccessPolicyCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=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_authorization.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accesspolicies"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + **kwargs: Any + ) -> _models.AuthorizationAccessPolicyContract: + """Gets the details of the authorization access policy specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. + :type authorization_id: str + :param authorization_access_policy_id: Identifier of the authorization access policy. + :type authorization_access_policy_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationAccessPolicyContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationAccessPolicyContract] + + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + authorization_access_policy_id=authorization_access_policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('AuthorizationAccessPolicyContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accesspolicies/{authorizationAccessPolicyId}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + parameters: _models.AuthorizationAccessPolicyContract, + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.AuthorizationAccessPolicyContract: + """Creates or updates Authorization Access Policy. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. + :type authorization_id: str + :param authorization_access_policy_id: Identifier of the authorization access policy. + :type authorization_access_policy_id: str + :param parameters: Create parameters. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationAccessPolicyContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationAccessPolicyContract] + + _json = self._serialize.body(parameters, 'AuthorizationAccessPolicyContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + authorization_access_policy_id=authorization_access_policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('AuthorizationAccessPolicyContract', pipeline_response) + + 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}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accesspolicies/{authorizationAccessPolicyId}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes specific access policy from the Authorization. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. + :type authorization_id: str + :param authorization_access_policy_id: Identifier of the authorization access policy. + :type authorization_access_policy_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + authorization_access_policy_id=authorization_access_policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = 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}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accesspolicies/{authorizationAccessPolicyId}"} # type: ignore + diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_login_links_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_login_links_operations.py new file mode 100644 index 000000000000..7ca7efddea22 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_login_links_operations.py @@ -0,0 +1,126 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._authorization_login_links_operations import build_post_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AuthorizationLoginLinksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`authorization_login_links` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def post( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: _models.AuthorizationLoginRequestContract, + **kwargs: Any + ) -> _models.AuthorizationLoginResponseContract: + """Gets authorization login links. + + :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 authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. + :type authorization_id: str + :param parameters: Create parameters. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationLoginRequestContract + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationLoginResponseContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationLoginResponseContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationLoginResponseContract] + + _json = self._serialize.body(parameters, 'AuthorizationLoginRequestContract') + + request = build_post_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.post.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('AuthorizationLoginResponseContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + post.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/getLoginLinks"} # type: ignore + diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_operations.py new file mode 100644 index 000000000000..02e4d08afd78 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_operations.py @@ -0,0 +1,396 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +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.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._authorization_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_authorization_provider_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AuthorizationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`authorization` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_authorization_provider( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AuthorizationCollection]: + """Lists a collection of authorization providers defined within a authorization provider. + + :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 authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AuthorizationCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AuthorizationCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationCollection] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_authorization_provider_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + top=top, + skip=skip, + template_url=self.list_by_authorization_provider.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_authorization_provider_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + top=top, + skip=skip, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AuthorizationCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=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_authorization_provider.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + **kwargs: Any + ) -> _models.AuthorizationContract: + """Gets the details of the authorization specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. + :type authorization_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationContract] + + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('AuthorizationContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: _models.AuthorizationContract, + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.AuthorizationContract: + """Creates or updates authorization. + + :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 authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. + :type authorization_id: str + :param parameters: Create parameters. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationContract] + + _json = self._serialize.body(parameters, 'AuthorizationContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('AuthorizationContract', pipeline_response) + + 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}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes specific Authorization from the Authorization provider. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. + :type authorization_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = 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}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}"} # type: ignore + diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_provider_operations.py new file mode 100644 index 000000000000..11774cfc5ebf --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_provider_operations.py @@ -0,0 +1,379 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +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.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._authorization_provider_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_service_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AuthorizationProviderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`authorization_provider` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncIterable[_models.AuthorizationProviderCollection]: + """Lists a collection of authorization providers defined within a 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 |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AuthorizationProviderCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AuthorizationProviderCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationProviderCollection] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + top=top, + skip=skip, + template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + top=top, + skip=skip, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AuthorizationProviderCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=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}/authorizationProviders"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + **kwargs: Any + ) -> _models.AuthorizationProviderContract: + """Gets the details of the authorization provider specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationProviderContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationProviderContract] + + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('AuthorizationProviderContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + parameters: _models.AuthorizationProviderContract, + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.AuthorizationProviderContract: + """Creates or updates authorization provider. + + :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 authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param parameters: Create parameters. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationProviderContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationProviderContract] + + _json = self._serialize.body(parameters, 'AuthorizationProviderContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('AuthorizationProviderContract', pipeline_response) + + 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}/authorizationProviders/{authorizationProviderId}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes specific authorization provider from the API Management service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = 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}/authorizationProviders/{authorizationProviderId}"} # 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 bbb4dffb2662..76568644d8ed 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_server_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_server_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._authorization_server_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_list_secrets_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AuthorizationServerOperations: - """AuthorizationServerOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`authorization_server` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -55,7 +54,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.AuthorizationServerCollection"]: + ) -> AsyncIterable[_models.AuthorizationServerCollection]: """Lists a collection of authorization servers defined within a service instance. :param resource_group_name: The name of the resource group. @@ -66,24 +65,29 @@ def list_by_service( functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
. + |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AuthorizationServerCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.AuthorizationServerCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AuthorizationServerCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationServerCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -91,13 +95,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -105,13 +112,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -125,7 +135,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,7 +153,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -162,11 +176,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -174,12 +193,19 @@ async def get_entity_tag( service_name=service_name, authsid=authsid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -195,7 +221,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # type: ignore @distributed_trace_async @@ -205,7 +231,7 @@ async def get( service_name: str, authsid: str, **kwargs: Any - ) -> "_models.AuthorizationServerContract": + ) -> _models.AuthorizationServerContract: """Gets the details of the authorization server specified by its identifier. :param resource_group_name: The name of the resource group. @@ -216,14 +242,19 @@ async def get( :type authsid: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AuthorizationServerContract, or the result of cls(response) - :rtype: ~api_management_client.models.AuthorizationServerContract + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationServerContract] request = build_get_request( @@ -231,12 +262,19 @@ async def get( service_name=service_name, authsid=authsid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -254,7 +292,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # type: ignore @distributed_trace_async @@ -263,10 +301,10 @@ async def create_or_update( resource_group_name: str, service_name: str, authsid: str, - parameters: "_models.AuthorizationServerContract", + parameters: _models.AuthorizationServerContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.AuthorizationServerContract": + ) -> _models.AuthorizationServerContract: """Creates new authorization server or updates an existing authorization server. :param resource_group_name: The name of the resource group. @@ -276,22 +314,26 @@ async def create_or_update( :param authsid: Identifier of the authorization server. :type authsid: str :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.AuthorizationServerContract + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AuthorizationServerContract, or the result of cls(response) - :rtype: ~api_management_client.models.AuthorizationServerContract + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationServerContract] _json = self._serialize.body(parameters, 'AuthorizationServerContract') @@ -300,15 +342,22 @@ async def create_or_update( service_name=service_name, authsid=authsid, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -332,7 +381,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # type: ignore @distributed_trace_async @@ -342,9 +391,9 @@ async def update( service_name: str, authsid: str, if_match: str, - parameters: "_models.AuthorizationServerUpdateContract", + parameters: _models.AuthorizationServerUpdateContract, **kwargs: Any - ) -> "_models.AuthorizationServerContract": + ) -> _models.AuthorizationServerContract: """Updates the details of the authorization server specified by its identifier. :param resource_group_name: The name of the resource group. @@ -357,19 +406,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: OAuth2 Server settings Update parameters. - :type parameters: ~api_management_client.models.AuthorizationServerUpdateContract + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerUpdateContract :keyword callable cls: A custom type or function that will be passed the direct response :return: AuthorizationServerContract, or the result of cls(response) - :rtype: ~api_management_client.models.AuthorizationServerContract + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationServerContract] _json = self._serialize.body(parameters, 'AuthorizationServerUpdateContract') @@ -378,15 +431,22 @@ async def update( service_name=service_name, authsid=authsid, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -404,11 +464,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -432,11 +492,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -444,13 +509,20 @@ async def delete( service_name=service_name, authsid=authsid, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -461,7 +533,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # type: ignore @distributed_trace_async @@ -471,7 +543,7 @@ async def list_secrets( service_name: str, authsid: str, **kwargs: Any - ) -> "_models.AuthorizationServerSecretsContract": + ) -> _models.AuthorizationServerSecretsContract: """Gets the client secret details of the authorization server. :param resource_group_name: The name of the resource group. @@ -482,14 +554,19 @@ async def list_secrets( :type authsid: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AuthorizationServerSecretsContract, or the result of cls(response) - :rtype: ~api_management_client.models.AuthorizationServerSecretsContract + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerSecretsContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerSecretsContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationServerSecretsContract] request = build_list_secrets_request( @@ -497,12 +574,19 @@ async def list_secrets( service_name=service_name, authsid=authsid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_secrets.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -520,5 +604,5 @@ async def list_secrets( return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}/listSecrets'} # type: ignore + list_secrets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_backend_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_backend_operations.py index 75335b4c780d..8b7514b274ae 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_backend_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_backend_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._backend_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_reconnect_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BackendOperations: - """BackendOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`backend` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -55,7 +54,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.BackendCollection"]: + ) -> AsyncIterable[_models.BackendCollection]: """Lists a collection of backends in the specified service instance. :param resource_group_name: The name of the resource group. @@ -66,23 +65,29 @@ def list_by_service( functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| title | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| url | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BackendCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.BackendCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.BackendCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackendCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BackendCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -90,13 +95,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -104,13 +112,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,7 +135,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -138,7 +153,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -162,11 +177,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -174,12 +194,19 @@ async def get_entity_tag( service_name=service_name, backend_id=backend_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -195,7 +222,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # type: ignore @distributed_trace_async @@ -205,7 +232,7 @@ async def get( service_name: str, backend_id: str, **kwargs: Any - ) -> "_models.BackendContract": + ) -> _models.BackendContract: """Gets the details of the backend specified by its identifier. :param resource_group_name: The name of the resource group. @@ -217,14 +244,19 @@ async def get( :type backend_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BackendContract, or the result of cls(response) - :rtype: ~api_management_client.models.BackendContract + :rtype: ~azure.mgmt.apimanagement.models.BackendContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackendContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BackendContract] request = build_get_request( @@ -232,12 +264,19 @@ async def get( service_name=service_name, backend_id=backend_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -255,7 +294,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # type: ignore @distributed_trace_async @@ -264,10 +303,10 @@ async def create_or_update( resource_group_name: str, service_name: str, backend_id: str, - parameters: "_models.BackendContract", + parameters: _models.BackendContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.BackendContract": + ) -> _models.BackendContract: """Creates or Updates a backend. :param resource_group_name: The name of the resource group. @@ -278,22 +317,26 @@ async def create_or_update( Management service instance. :type backend_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.BackendContract + :type parameters: ~azure.mgmt.apimanagement.models.BackendContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BackendContract, or the result of cls(response) - :rtype: ~api_management_client.models.BackendContract + :rtype: ~azure.mgmt.apimanagement.models.BackendContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackendContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.BackendContract] _json = self._serialize.body(parameters, 'BackendContract') @@ -302,15 +345,22 @@ async def create_or_update( service_name=service_name, backend_id=backend_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -334,7 +384,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # type: ignore @distributed_trace_async @@ -344,9 +394,9 @@ async def update( service_name: str, backend_id: str, if_match: str, - parameters: "_models.BackendUpdateParameters", + parameters: _models.BackendUpdateParameters, **kwargs: Any - ) -> "_models.BackendContract": + ) -> _models.BackendContract: """Updates an existing backend. :param resource_group_name: The name of the resource group. @@ -360,19 +410,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.BackendUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.BackendUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: BackendContract, or the result of cls(response) - :rtype: ~api_management_client.models.BackendContract + :rtype: ~azure.mgmt.apimanagement.models.BackendContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackendContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.BackendContract] _json = self._serialize.body(parameters, 'BackendUpdateParameters') @@ -381,15 +435,22 @@ async def update( service_name=service_name, backend_id=backend_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,11 +468,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -436,11 +497,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -448,13 +514,20 @@ async def delete( service_name=service_name, backend_id=backend_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -465,16 +538,16 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # type: ignore @distributed_trace_async - async def reconnect( + async def reconnect( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, backend_id: str, - parameters: Optional["_models.BackendReconnectContract"] = None, + parameters: Optional[_models.BackendReconnectContract] = None, **kwargs: Any ) -> None: """Notifies the APIM proxy to create a new connection to the backend after the specified timeout. @@ -487,20 +560,24 @@ async def reconnect( :param backend_id: Identifier of the Backend entity. Must be unique in the current API Management service instance. :type backend_id: str - :param parameters: Reconnect request parameters. - :type parameters: ~api_management_client.models.BackendReconnectContract + :param parameters: Reconnect request parameters. Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.BackendReconnectContract :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'BackendReconnectContract') @@ -512,14 +589,21 @@ async def reconnect( service_name=service_name, backend_id=backend_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.reconnect.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [202]: @@ -530,5 +614,5 @@ async def reconnect( if cls: return cls(pipeline_response, None, {}) - reconnect.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}/reconnect'} # type: ignore + reconnect.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}/reconnect"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_cache_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_cache_operations.py index 4d89b755ee3b..0e037d9d9bc6 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_cache_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_cache_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._cache_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CacheOperations: - """CacheOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`cache` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -54,27 +53,33 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.CacheCollection"]: + ) -> AsyncIterable[_models.CacheCollection]: """Lists a collection of all external Caches in the specified 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 top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CacheCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.CacheCollection] + :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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CacheCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -82,12 +87,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -95,12 +103,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -114,7 +125,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -128,7 +143,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -152,11 +167,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -164,12 +184,19 @@ async def get_entity_tag( service_name=service_name, cache_id=cache_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -185,7 +212,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # type: ignore @distributed_trace_async @@ -195,7 +222,7 @@ async def get( service_name: str, cache_id: str, **kwargs: Any - ) -> "_models.CacheContract": + ) -> _models.CacheContract: """Gets the details of the Cache specified by its identifier. :param resource_group_name: The name of the resource group. @@ -207,14 +234,19 @@ async def get( :type cache_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CacheContract, or the result of cls(response) - :rtype: ~api_management_client.models.CacheContract + :rtype: ~azure.mgmt.apimanagement.models.CacheContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CacheContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CacheContract] request = build_get_request( @@ -222,12 +254,19 @@ async def get( service_name=service_name, cache_id=cache_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -245,7 +284,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # type: ignore @distributed_trace_async @@ -254,10 +293,10 @@ async def create_or_update( resource_group_name: str, service_name: str, cache_id: str, - parameters: "_models.CacheContract", + parameters: _models.CacheContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CacheContract": + ) -> _models.CacheContract: """Creates or updates an External Cache to be used in Api Management instance. :param resource_group_name: The name of the resource group. @@ -268,22 +307,26 @@ async def create_or_update( or valid Azure region identifier). :type cache_id: str :param parameters: Create or Update parameters. - :type parameters: ~api_management_client.models.CacheContract + :type parameters: ~azure.mgmt.apimanagement.models.CacheContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CacheContract, or the result of cls(response) - :rtype: ~api_management_client.models.CacheContract + :rtype: ~azure.mgmt.apimanagement.models.CacheContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CacheContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CacheContract] _json = self._serialize.body(parameters, 'CacheContract') @@ -292,15 +335,22 @@ async def create_or_update( service_name=service_name, cache_id=cache_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -324,7 +374,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # type: ignore @distributed_trace_async @@ -334,9 +384,9 @@ async def update( service_name: str, cache_id: str, if_match: str, - parameters: "_models.CacheUpdateParameters", + parameters: _models.CacheUpdateParameters, **kwargs: Any - ) -> "_models.CacheContract": + ) -> _models.CacheContract: """Updates the details of the cache specified by its identifier. :param resource_group_name: The name of the resource group. @@ -350,19 +400,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.CacheUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.CacheUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: CacheContract, or the result of cls(response) - :rtype: ~api_management_client.models.CacheContract + :rtype: ~azure.mgmt.apimanagement.models.CacheContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CacheContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CacheContract] _json = self._serialize.body(parameters, 'CacheUpdateParameters') @@ -371,15 +425,22 @@ async def update( service_name=service_name, cache_id=cache_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -397,11 +458,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -426,11 +487,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -438,13 +504,20 @@ async def delete( service_name=service_name, cache_id=cache_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -455,5 +528,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_certificate_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_certificate_operations.py index ab26b2c72737..e72c12f909e0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_certificate_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_certificate_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._certificate_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_refresh_secret_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CertificateOperations: - """CertificateOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`certificate` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -56,7 +55,7 @@ def list_by_service( skip: Optional[int] = None, is_key_vault_refresh_failed: Optional[bool] = None, **kwargs: Any - ) -> AsyncIterable["_models.CertificateCollection"]: + ) -> AsyncIterable[_models.CertificateCollection]: """Lists a collection of all certificates in the specified service instance. :param resource_group_name: The name of the resource group. @@ -68,27 +67,32 @@ def list_by_service( filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| subject | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| thumbprint | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
| expirationDate | filter | ge, le, eq, ne, gt, lt | |
. + |
| expirationDate | filter | ge, le, eq, ne, gt, lt | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :param is_key_vault_refresh_failed: When set to true, the response contains only certificates - entities which failed refresh. + entities which failed refresh. Default value is None. :type is_key_vault_refresh_failed: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CertificateCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.CertificateCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.CertificateCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CertificateCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -96,14 +100,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, is_key_vault_refresh_failed=is_key_vault_refresh_failed, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -111,14 +118,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, is_key_vault_refresh_failed=is_key_vault_refresh_failed, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -132,7 +142,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,7 +160,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -170,11 +184,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -182,12 +201,19 @@ async def get_entity_tag( service_name=service_name, certificate_id=certificate_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -203,7 +229,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}"} # type: ignore @distributed_trace_async @@ -213,7 +239,7 @@ async def get( service_name: str, certificate_id: str, **kwargs: Any - ) -> "_models.CertificateContract": + ) -> _models.CertificateContract: """Gets the details of the certificate specified by its identifier. :param resource_group_name: The name of the resource group. @@ -225,14 +251,19 @@ async def get( :type certificate_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateContract, or the result of cls(response) - :rtype: ~api_management_client.models.CertificateContract + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CertificateContract] request = build_get_request( @@ -240,12 +271,19 @@ async def get( service_name=service_name, certificate_id=certificate_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -263,7 +301,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}"} # type: ignore @distributed_trace_async @@ -272,10 +310,10 @@ async def create_or_update( resource_group_name: str, service_name: str, certificate_id: str, - parameters: "_models.CertificateCreateOrUpdateParameters", + parameters: _models.CertificateCreateOrUpdateParameters, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateContract": + ) -> _models.CertificateContract: """Creates or updates the certificate being used for authentication with the backend. :param resource_group_name: The name of the resource group. @@ -286,22 +324,26 @@ async def create_or_update( Management service instance. :type certificate_id: str :param parameters: Create or Update parameters. - :type parameters: ~api_management_client.models.CertificateCreateOrUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.CertificateCreateOrUpdateParameters :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateContract, or the result of cls(response) - :rtype: ~api_management_client.models.CertificateContract + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CertificateContract] _json = self._serialize.body(parameters, 'CertificateCreateOrUpdateParameters') @@ -310,15 +352,22 @@ async def create_or_update( service_name=service_name, certificate_id=certificate_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -342,11 +391,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -371,11 +420,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -383,13 +437,20 @@ async def delete( service_name=service_name, certificate_id=certificate_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -400,7 +461,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}"} # type: ignore @distributed_trace_async @@ -410,7 +471,7 @@ async def refresh_secret( service_name: str, certificate_id: str, **kwargs: Any - ) -> "_models.CertificateContract": + ) -> _models.CertificateContract: """From KeyVault, Refresh the certificate being used for authentication with the backend. :param resource_group_name: The name of the resource group. @@ -422,14 +483,19 @@ async def refresh_secret( :type certificate_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateContract, or the result of cls(response) - :rtype: ~api_management_client.models.CertificateContract + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CertificateContract] request = build_refresh_secret_request( @@ -437,12 +503,19 @@ async def refresh_secret( service_name=service_name, certificate_id=certificate_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.refresh_secret.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -460,5 +533,5 @@ async def refresh_secret( return deserialized - refresh_secret.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}/refreshSecret'} # type: ignore + refresh_secret.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}/refreshSecret"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_item_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_item_operations.py index 4a2398e809da..4cee10c181e8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_item_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_item_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._content_item_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ContentItemOperations: - """ContentItemOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`content_item` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -53,7 +52,7 @@ def list_by_service( service_name: str, content_type_id: str, **kwargs: Any - ) -> AsyncIterable["_models.ContentItemCollection"]: + ) -> AsyncIterable[_models.ContentItemCollection]: """Lists developer portal's content items specified by the provided content type. :param resource_group_name: The name of the resource group. @@ -66,14 +65,19 @@ def list_by_service( :return: An iterator like instance of either ContentItemCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ContentItemCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ContentItemCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentItemCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentItemCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -82,10 +86,13 @@ def prepare_request(next_link=None): service_name=service_name, content_type_id=content_type_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -94,10 +101,13 @@ def prepare_request(next_link=None): service_name=service_name, content_type_id=content_type_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -111,7 +121,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -125,7 +139,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -152,11 +166,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -165,12 +184,19 @@ async def get_entity_tag( content_type_id=content_type_id, content_item_id=content_item_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,7 +212,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}"} # type: ignore @distributed_trace_async @@ -197,7 +223,7 @@ async def get( content_type_id: str, content_item_id: str, **kwargs: Any - ) -> "_models.ContentItemContract": + ) -> _models.ContentItemContract: """Returns the developer portal's content item specified by its identifier. :param resource_group_name: The name of the resource group. @@ -210,14 +236,19 @@ async def get( :type content_item_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ContentItemContract, or the result of cls(response) - :rtype: ~api_management_client.models.ContentItemContract + :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentItemContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentItemContract] request = build_get_request( @@ -226,12 +257,19 @@ async def get( content_type_id=content_type_id, content_item_id=content_item_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -249,7 +287,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}"} # type: ignore @distributed_trace_async @@ -261,7 +299,7 @@ async def create_or_update( content_item_id: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ContentItemContract": + ) -> _models.ContentItemContract: """Creates a new developer portal's content item specified by the provided content type. :param resource_group_name: The name of the resource group. @@ -273,18 +311,23 @@ async def create_or_update( :param content_item_id: Content item identifier. :type content_item_id: str :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ContentItemContract, or the result of cls(response) - :rtype: ~api_management_client.models.ContentItemContract + :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentItemContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentItemContract] request = build_create_or_update_request( @@ -293,13 +336,20 @@ async def create_or_update( content_type_id=content_type_id, content_item_id=content_item_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -323,11 +373,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -354,11 +404,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -367,13 +422,20 @@ async def delete( content_type_id=content_type_id, content_item_id=content_item_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -384,5 +446,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_operations.py index 1585a8e5ad8b..b5df98edd4b0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._content_type_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ContentTypeOperations: - """ContentTypeOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`content_type` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -52,7 +51,7 @@ def list_by_service( resource_group_name: str, service_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ContentTypeCollection"]: + ) -> AsyncIterable[_models.ContentTypeCollection]: """Lists the developer portal's content types. Content types describe content items' properties, validation rules, and constraints. @@ -64,14 +63,19 @@ def list_by_service( :return: An iterator like instance of either ContentTypeCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ContentTypeCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ContentTypeCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentTypeCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentTypeCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,10 +83,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -90,10 +97,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -107,7 +117,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,7 +135,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes"} # type: ignore @distributed_trace_async async def get( @@ -130,7 +144,7 @@ async def get( service_name: str, content_type_id: str, **kwargs: Any - ) -> "_models.ContentTypeContract": + ) -> _models.ContentTypeContract: """Gets the details of the developer portal's content type. Content types describe content items' properties, validation rules, and constraints. @@ -142,14 +156,19 @@ async def get( :type content_type_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ContentTypeContract, or the result of cls(response) - :rtype: ~api_management_client.models.ContentTypeContract + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentTypeContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentTypeContract] request = build_get_request( @@ -157,12 +176,19 @@ async def get( service_name=service_name, content_type_id=content_type_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -180,7 +206,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}"} # type: ignore @distributed_trace_async @@ -190,8 +216,9 @@ async def create_or_update( service_name: str, content_type_id: str, if_match: Optional[str] = None, + parameters: Optional[_models.ContentTypeContract] = None, **kwargs: Any - ) -> "_models.ContentTypeContract": + ) -> _models.ContentTypeContract: """Creates or updates the developer portal's content type. Content types describe content items' properties, validation rules, and constraints. Custom content types' identifiers need to start with the ``c-`` prefix. Built-in content types can't be modified. @@ -203,32 +230,53 @@ async def create_or_update( :param content_type_id: Content type identifier. :type content_type_id: str :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :param parameters: Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.ContentTypeContract :keyword callable cls: A custom type or function that will be passed the direct response :return: ContentTypeContract, or the result of cls(response) - :rtype: ~api_management_client.models.ContentTypeContract + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentTypeContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentTypeContract] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ContentTypeContract') + else: + _json = None - 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, + api_version=api_version, + content_type=content_type, + json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -252,11 +300,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -282,11 +330,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -294,13 +347,20 @@ async def delete( service_name=service_name, content_type_id=content_type_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -311,5 +371,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_delegation_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_delegation_settings_operations.py index 46526b90ade2..0a26df363b61 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_delegation_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_delegation_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,44 +6,42 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._delegation_settings_operations import build_create_or_update_request, build_get_entity_tag_request, build_get_request, build_list_secrets_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DelegationSettingsOperations: - """DelegationSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`delegation_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get_entity_tag( @@ -62,23 +61,35 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -94,7 +105,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation"} # type: ignore @distributed_trace_async @@ -103,7 +114,7 @@ async def get( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.PortalDelegationSettings": + ) -> _models.PortalDelegationSettings: """Get Delegation Settings for the Portal. :param resource_group_name: The name of the resource group. @@ -112,26 +123,38 @@ async def get( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PortalDelegationSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalDelegationSettings + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalDelegationSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalDelegationSettings] request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -149,16 +172,16 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation"} # type: ignore @distributed_trace_async - async def update( + async def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, if_match: str, - parameters: "_models.PortalDelegationSettings", + parameters: _models.PortalDelegationSettings, **kwargs: Any ) -> None: """Update Delegation settings. @@ -171,19 +194,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update Delegation settings. - :type parameters: ~api_management_client.models.PortalDelegationSettings + :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(parameters, 'PortalDelegationSettings') @@ -191,15 +218,22 @@ async def update( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -210,7 +244,7 @@ async def update( if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation"} # type: ignore @distributed_trace_async @@ -218,10 +252,10 @@ async def create_or_update( self, resource_group_name: str, service_name: str, - parameters: "_models.PortalDelegationSettings", + parameters: _models.PortalDelegationSettings, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PortalDelegationSettings": + ) -> _models.PortalDelegationSettings: """Create or Update Delegation settings. :param resource_group_name: The name of the resource group. @@ -229,22 +263,26 @@ async def create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.PortalDelegationSettings + :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PortalDelegationSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalDelegationSettings + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalDelegationSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalDelegationSettings] _json = self._serialize.body(parameters, 'PortalDelegationSettings') @@ -252,15 +290,22 @@ async def create_or_update( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -275,7 +320,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation"} # type: ignore @distributed_trace_async @@ -284,7 +329,7 @@ async def list_secrets( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.PortalSettingValidationKeyContract": + ) -> _models.PortalSettingValidationKeyContract: """Gets the secret validation key of the DelegationSettings. :param resource_group_name: The name of the resource group. @@ -293,26 +338,38 @@ async def list_secrets( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PortalSettingValidationKeyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSettingValidationKeyContract + :rtype: ~azure.mgmt.apimanagement.models.PortalSettingValidationKeyContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSettingValidationKeyContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalSettingValidationKeyContract] request = build_list_secrets_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_secrets.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -327,5 +384,5 @@ async def list_secrets( return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation/listSecrets'} # type: ignore + list_secrets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_deleted_services_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_deleted_services_operations.py index f8fc7ea2823a..8bd135f3d53a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_deleted_services_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_deleted_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,74 +16,85 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request from ...operations._deleted_services_operations import build_get_by_name_request, build_list_by_subscription_request, build_purge_request_initial +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DeletedServicesOperations: - """DeletedServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`deleted_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.DeletedServicesCollection"]: + ) -> AsyncIterable[_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.async_paging.AsyncItemPaged[~api_management_client.models.DeletedServicesCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DeletedServicesCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedServicesCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedServicesCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -98,7 +108,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,7 +126,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices"} # type: ignore @distributed_trace_async async def get_by_name( @@ -120,7 +134,7 @@ async def get_by_name( service_name: str, location: str, **kwargs: Any - ) -> "_models.DeletedServiceContract": + ) -> _models.DeletedServiceContract: """Get soft-deleted Api Management Service by name. :param service_name: The name of the API Management service. @@ -129,26 +143,38 @@ async def get_by_name( :type location: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedServiceContract, or the result of cls(response) - :rtype: ~api_management_client.models.DeletedServiceContract + :rtype: ~azure.mgmt.apimanagement.models.DeletedServiceContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedServiceContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedServiceContract] request = build_get_by_name_request( service_name=service_name, subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.get_by_name.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -163,7 +189,7 @@ async def get_by_name( return deserialized - get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}'} # type: ignore + get_by_name.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}"} # type: ignore async def _purge_initial( @@ -171,24 +197,36 @@ async def _purge_initial( service_name: str, location: str, **kwargs: Any - ) -> Optional["_models.DeletedServiceContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeletedServiceContract"]] + ) -> Optional[_models.DeletedServiceContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.DeletedServiceContract]] request = build_purge_request_initial( service_name=service_name, subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self._purge_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -204,7 +242,7 @@ async def _purge_initial( return deserialized - _purge_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}'} # type: ignore + _purge_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}"} # type: ignore @distributed_trace_async @@ -213,7 +251,7 @@ async def begin_purge( service_name: str, location: str, **kwargs: Any - ) -> AsyncLROPoller["_models.DeletedServiceContract"]: + ) -> AsyncLROPoller[_models.DeletedServiceContract]: """Purges Api Management Service (deletes it with no option to undelete). :param service_name: The name of the API Management service. @@ -231,35 +269,47 @@ async def begin_purge( :return: An instance of AsyncLROPoller that returns either DeletedServiceContract or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.DeletedServiceContract] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.DeletedServiceContract] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedServiceContract"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedServiceContract] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._purge_initial( + raw_result = await self._purge_initial( # type: ignore service_name=service_name, location=location, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -268,7 +318,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_purge.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}'} # type: ignore + begin_purge.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_diagnostic_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_diagnostic_operations.py index 9e620c5eb715..27bfd373b635 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_diagnostic_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_diagnostic_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._diagnostic_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiagnosticOperations: - """DiagnosticOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`diagnostic` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -55,7 +54,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.DiagnosticCollection"]: + ) -> AsyncIterable[_models.DiagnosticCollection]: """Lists all diagnostics of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -64,24 +63,30 @@ def list_by_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 |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DiagnosticCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.DiagnosticCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DiagnosticCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -89,13 +94,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -103,13 +111,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -123,7 +134,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -137,7 +152,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -161,11 +176,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -173,12 +193,19 @@ async def get_entity_tag( service_name=service_name, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -194,7 +221,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace_async @@ -204,7 +231,7 @@ async def get( service_name: str, diagnostic_id: str, **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _models.DiagnosticContract: """Gets the details of the Diagnostic specified by its identifier. :param resource_group_name: The name of the resource group. @@ -216,14 +243,19 @@ async def get( :type diagnostic_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticContract] request = build_get_request( @@ -231,12 +263,19 @@ async def get( service_name=service_name, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -254,7 +293,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace_async @@ -263,10 +302,10 @@ async def create_or_update( resource_group_name: str, service_name: str, diagnostic_id: str, - parameters: "_models.DiagnosticContract", + parameters: _models.DiagnosticContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _models.DiagnosticContract: """Creates a new Diagnostic or updates an existing one. :param resource_group_name: The name of the resource group. @@ -277,22 +316,26 @@ async def create_or_update( service instance. :type diagnostic_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.DiagnosticContract + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticContract] _json = self._serialize.body(parameters, 'DiagnosticContract') @@ -301,15 +344,22 @@ async def create_or_update( service_name=service_name, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -333,7 +383,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace_async @@ -343,9 +393,9 @@ async def update( service_name: str, diagnostic_id: str, if_match: str, - parameters: "_models.DiagnosticContract", + parameters: _models.DiagnosticContract, **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _models.DiagnosticContract: """Updates the details of the Diagnostic specified by its identifier. :param resource_group_name: The name of the resource group. @@ -359,19 +409,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Diagnostic Update parameters. - :type parameters: ~api_management_client.models.DiagnosticContract + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticContract] _json = self._serialize.body(parameters, 'DiagnosticContract') @@ -380,15 +434,22 @@ async def update( service_name=service_name, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -406,11 +467,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -435,11 +496,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -447,13 +513,20 @@ async def delete( service_name=service_name, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -464,5 +537,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_email_template_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_email_template_operations.py index 88ef6c0e8bd2..972de5f43287 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_email_template_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_email_template_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._email_template_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class EmailTemplateOperations: - """EmailTemplateOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`email_template` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -55,7 +54,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.EmailTemplateCollection"]: + ) -> AsyncIterable[_models.EmailTemplateCollection]: """Gets all email templates. :param resource_group_name: The name of the resource group. @@ -64,24 +63,30 @@ def list_by_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 |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EmailTemplateCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.EmailTemplateCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.EmailTemplateCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EmailTemplateCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EmailTemplateCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -89,13 +94,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -103,13 +111,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -123,7 +134,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -137,7 +152,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -154,17 +169,22 @@ async def get_entity_tag( :param service_name: The name of the API Management service. :type service_name: str :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName :keyword callable cls: A custom type or function that will be passed the direct response :return: bool, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -172,12 +192,19 @@ async def get_entity_tag( service_name=service_name, template_name=template_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -193,7 +220,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # type: ignore @distributed_trace_async @@ -203,7 +230,7 @@ async def get( service_name: str, template_name: Union[str, "_models.TemplateName"], **kwargs: Any - ) -> "_models.EmailTemplateContract": + ) -> _models.EmailTemplateContract: """Gets the details of the email template specified by its identifier. :param resource_group_name: The name of the resource group. @@ -211,17 +238,22 @@ async def get( :param service_name: The name of the API Management service. :type service_name: str :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName :keyword callable cls: A custom type or function that will be passed the direct response :return: EmailTemplateContract, or the result of cls(response) - :rtype: ~api_management_client.models.EmailTemplateContract + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EmailTemplateContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EmailTemplateContract] request = build_get_request( @@ -229,12 +261,19 @@ async def get( service_name=service_name, template_name=template_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -252,7 +291,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # type: ignore @distributed_trace_async @@ -261,10 +300,10 @@ async def create_or_update( resource_group_name: str, service_name: str, template_name: Union[str, "_models.TemplateName"], - parameters: "_models.EmailTemplateUpdateParameters", + parameters: _models.EmailTemplateUpdateParameters, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.EmailTemplateContract": + ) -> _models.EmailTemplateContract: """Updates an Email Template. :param resource_group_name: The name of the resource group. @@ -272,24 +311,28 @@ async def create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName :param parameters: Email Template update parameters. - :type parameters: ~api_management_client.models.EmailTemplateUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: EmailTemplateContract, or the result of cls(response) - :rtype: ~api_management_client.models.EmailTemplateContract + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EmailTemplateContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.EmailTemplateContract] _json = self._serialize.body(parameters, 'EmailTemplateUpdateParameters') @@ -298,15 +341,22 @@ async def create_or_update( service_name=service_name, template_name=template_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -325,7 +375,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # type: ignore @distributed_trace_async @@ -335,9 +385,9 @@ async def update( service_name: str, template_name: Union[str, "_models.TemplateName"], if_match: str, - parameters: "_models.EmailTemplateUpdateParameters", + parameters: _models.EmailTemplateUpdateParameters, **kwargs: Any - ) -> "_models.EmailTemplateContract": + ) -> _models.EmailTemplateContract: """Updates API Management email template. :param resource_group_name: The name of the resource group. @@ -345,24 +395,28 @@ async def update( :param service_name: The name of the API Management service. :type service_name: str :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.EmailTemplateUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: EmailTemplateContract, or the result of cls(response) - :rtype: ~api_management_client.models.EmailTemplateContract + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EmailTemplateContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.EmailTemplateContract] _json = self._serialize.body(parameters, 'EmailTemplateUpdateParameters') @@ -371,15 +425,22 @@ async def update( service_name=service_name, template_name=template_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -397,11 +458,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -416,7 +477,7 @@ async def delete( :param service_name: The name of the API Management service. :type service_name: str :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str @@ -425,11 +486,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -437,13 +503,20 @@ async def delete( service_name=service_name, template_name=template_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -454,5 +527,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_api_operations.py index 8c2df8e97d6f..6c683cd37c29 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_api_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_api_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._gateway_api_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GatewayApiOperations: - """GatewayApiOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`gateway_api` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -56,7 +55,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ApiCollection"]: + ) -> AsyncIterable[_models.ApiCollection]: """Lists a collection of the APIs associated with a gateway. :param resource_group_name: The name of the resource group. @@ -68,22 +67,28 @@ def list_by_service( :type gateway_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ApiCollection] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -92,13 +97,16 @@ def prepare_request(next_link=None): service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -107,13 +115,16 @@ def prepare_request(next_link=None): service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -127,7 +138,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,7 +156,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -168,11 +183,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -181,12 +201,19 @@ async def get_entity_tag( gateway_id=gateway_id, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -202,7 +229,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}"} # type: ignore @distributed_trace_async @@ -212,9 +239,9 @@ async def create_or_update( service_name: str, gateway_id: str, api_id: str, - parameters: Optional["_models.AssociationContract"] = None, + parameters: Optional[_models.AssociationContract] = None, **kwargs: Any - ) -> "_models.ApiContract": + ) -> _models.ApiContract: """Adds an API to the specified Gateway. :param resource_group_name: The name of the resource group. @@ -226,20 +253,24 @@ async def create_or_update( :type gateway_id: str :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param parameters: - :type parameters: ~api_management_client.models.AssociationContract + :param parameters: Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.AssociationContract :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiContract + :rtype: ~azure.mgmt.apimanagement.models.ApiContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiContract] if parameters is not None: _json = self._serialize.body(parameters, 'AssociationContract') @@ -252,14 +283,21 @@ async def create_or_update( gateway_id=gateway_id, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -278,11 +316,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -306,11 +344,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -319,12 +362,19 @@ async def delete( gateway_id=gateway_id, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -335,5 +385,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_certificate_authority_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_certificate_authority_operations.py index ca28a4ce94ea..07257c748748 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_certificate_authority_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_certificate_authority_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._gateway_certificate_authority_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GatewayCertificateAuthorityOperations: - """GatewayCertificateAuthorityOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`gateway_certificate_authority` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -56,7 +55,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.GatewayCertificateAuthorityCollection"]: + ) -> AsyncIterable[_models.GatewayCertificateAuthorityCollection]: """Lists the collection of Certificate Authorities for the specified Gateway entity. :param resource_group_name: The name of the resource group. @@ -68,24 +67,29 @@ def list_by_service( :type gateway_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | - filter | eq, ne | |
. + filter | eq, ne | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GatewayCertificateAuthorityCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.GatewayCertificateAuthorityCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCertificateAuthorityCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayCertificateAuthorityCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -94,13 +98,16 @@ def prepare_request(next_link=None): service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -109,13 +116,16 @@ def prepare_request(next_link=None): service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,7 +139,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -143,7 +157,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -171,11 +185,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -184,12 +203,19 @@ async def get_entity_tag( gateway_id=gateway_id, certificate_id=certificate_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -205,7 +231,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}"} # type: ignore @distributed_trace_async @@ -216,7 +242,7 @@ async def get( gateway_id: str, certificate_id: str, **kwargs: Any - ) -> "_models.GatewayCertificateAuthorityContract": + ) -> _models.GatewayCertificateAuthorityContract: """Get assigned Gateway Certificate Authority details. :param resource_group_name: The name of the resource group. @@ -231,14 +257,19 @@ async def get( :type certificate_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GatewayCertificateAuthorityContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayCertificateAuthorityContract + :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCertificateAuthorityContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayCertificateAuthorityContract] request = build_get_request( @@ -247,12 +278,19 @@ async def get( gateway_id=gateway_id, certificate_id=certificate_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -270,7 +308,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}"} # type: ignore @distributed_trace_async @@ -280,10 +318,10 @@ async def create_or_update( service_name: str, gateway_id: str, certificate_id: str, - parameters: "_models.GatewayCertificateAuthorityContract", + parameters: _models.GatewayCertificateAuthorityContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.GatewayCertificateAuthorityContract": + ) -> _models.GatewayCertificateAuthorityContract: """Assign Certificate entity to Gateway entity as Certificate Authority. :param resource_group_name: The name of the resource group. @@ -297,22 +335,26 @@ async def create_or_update( Management service instance. :type certificate_id: str :param parameters: - :type parameters: ~api_management_client.models.GatewayCertificateAuthorityContract + :type parameters: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GatewayCertificateAuthorityContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayCertificateAuthorityContract + :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCertificateAuthorityContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayCertificateAuthorityContract] _json = self._serialize.body(parameters, 'GatewayCertificateAuthorityContract') @@ -322,15 +364,22 @@ async def create_or_update( gateway_id=gateway_id, certificate_id=certificate_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -354,11 +403,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -387,11 +436,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -400,13 +454,20 @@ async def delete( gateway_id=gateway_id, certificate_id=certificate_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -417,5 +478,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_hostname_configuration_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_hostname_configuration_operations.py index 377299dba9ce..949d100e1cca 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_hostname_configuration_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_hostname_configuration_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._gateway_hostname_configuration_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GatewayHostnameConfigurationOperations: - """GatewayHostnameConfigurationOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`gateway_hostname_configuration` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -56,7 +55,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.GatewayHostnameConfigurationCollection"]: + ) -> AsyncIterable[_models.GatewayHostnameConfigurationCollection]: """Lists the collection of hostname configurations for the specified gateway. :param resource_group_name: The name of the resource group. @@ -69,24 +68,30 @@ def list_by_service( :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| hostname - | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GatewayHostnameConfigurationCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.GatewayHostnameConfigurationCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayHostnameConfigurationCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayHostnameConfigurationCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -95,13 +100,16 @@ def prepare_request(next_link=None): service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -110,13 +118,16 @@ def prepare_request(next_link=None): service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -130,7 +141,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -144,7 +159,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -173,11 +188,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -186,12 +206,19 @@ async def get_entity_tag( gateway_id=gateway_id, hc_id=hc_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -207,7 +234,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}"} # type: ignore @distributed_trace_async @@ -218,7 +245,7 @@ async def get( gateway_id: str, hc_id: str, **kwargs: Any - ) -> "_models.GatewayHostnameConfigurationContract": + ) -> _models.GatewayHostnameConfigurationContract: """Get details of a hostname configuration. :param resource_group_name: The name of the resource group. @@ -233,14 +260,19 @@ async def get( :type hc_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GatewayHostnameConfigurationContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayHostnameConfigurationContract + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayHostnameConfigurationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayHostnameConfigurationContract] request = build_get_request( @@ -249,12 +281,19 @@ async def get( gateway_id=gateway_id, hc_id=hc_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -272,7 +311,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}"} # type: ignore @distributed_trace_async @@ -282,10 +321,10 @@ async def create_or_update( service_name: str, gateway_id: str, hc_id: str, - parameters: "_models.GatewayHostnameConfigurationContract", + parameters: _models.GatewayHostnameConfigurationContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.GatewayHostnameConfigurationContract": + ) -> _models.GatewayHostnameConfigurationContract: """Creates of updates hostname configuration for a Gateway. :param resource_group_name: The name of the resource group. @@ -299,22 +338,26 @@ async def create_or_update( Gateway entity. :type hc_id: str :param parameters: - :type parameters: ~api_management_client.models.GatewayHostnameConfigurationContract + :type parameters: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GatewayHostnameConfigurationContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayHostnameConfigurationContract + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayHostnameConfigurationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayHostnameConfigurationContract] _json = self._serialize.body(parameters, 'GatewayHostnameConfigurationContract') @@ -324,15 +367,22 @@ async def create_or_update( gateway_id=gateway_id, hc_id=hc_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -356,11 +406,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -389,11 +439,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -402,13 +457,20 @@ async def delete( gateway_id=gateway_id, hc_id=hc_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -419,5 +481,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_operations.py index 9532624637ec..dd6d7417524d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._gateway_operations import build_create_or_update_request, build_delete_request, build_generate_token_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_list_keys_request, build_regenerate_key_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GatewayOperations: - """GatewayOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`gateway` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -55,7 +54,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.GatewayCollection"]: + ) -> AsyncIterable[_models.GatewayCollection]: """Lists a collection of gateways registered with service instance. :param resource_group_name: The name of the resource group. @@ -67,23 +66,28 @@ def list_by_service( filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| region | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
. + |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GatewayCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.GatewayCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -91,13 +95,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -105,13 +112,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -125,7 +135,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,7 +153,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -163,11 +177,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -175,12 +194,19 @@ async def get_entity_tag( service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -196,7 +222,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # type: ignore @distributed_trace_async @@ -206,7 +232,7 @@ async def get( service_name: str, gateway_id: str, **kwargs: Any - ) -> "_models.GatewayContract": + ) -> _models.GatewayContract: """Gets the details of the Gateway specified by its identifier. :param resource_group_name: The name of the resource group. @@ -218,14 +244,19 @@ async def get( :type gateway_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GatewayContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayContract + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayContract] request = build_get_request( @@ -233,12 +264,19 @@ async def get( service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -256,7 +294,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # type: ignore @distributed_trace_async @@ -265,10 +303,10 @@ async def create_or_update( resource_group_name: str, service_name: str, gateway_id: str, - parameters: "_models.GatewayContract", + parameters: _models.GatewayContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.GatewayContract": + ) -> _models.GatewayContract: """Creates or updates a Gateway to be used in Api Management instance. :param resource_group_name: The name of the resource group. @@ -279,22 +317,26 @@ async def create_or_update( service instance. Must not have value 'managed'. :type gateway_id: str :param parameters: - :type parameters: ~api_management_client.models.GatewayContract + :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GatewayContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayContract + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayContract] _json = self._serialize.body(parameters, 'GatewayContract') @@ -303,15 +345,22 @@ async def create_or_update( service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -335,7 +384,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # type: ignore @distributed_trace_async @@ -345,9 +394,9 @@ async def update( service_name: str, gateway_id: str, if_match: str, - parameters: "_models.GatewayContract", + parameters: _models.GatewayContract, **kwargs: Any - ) -> "_models.GatewayContract": + ) -> _models.GatewayContract: """Updates the details of the gateway specified by its identifier. :param resource_group_name: The name of the resource group. @@ -361,19 +410,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: - :type parameters: ~api_management_client.models.GatewayContract + :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract :keyword callable cls: A custom type or function that will be passed the direct response :return: GatewayContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayContract + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayContract] _json = self._serialize.body(parameters, 'GatewayContract') @@ -382,15 +435,22 @@ async def update( service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -408,11 +468,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -437,11 +497,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -449,13 +514,20 @@ async def delete( service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -466,7 +538,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # type: ignore @distributed_trace_async @@ -476,7 +548,7 @@ async def list_keys( service_name: str, gateway_id: str, **kwargs: Any - ) -> "_models.GatewayKeysContract": + ) -> _models.GatewayKeysContract: """Retrieves gateway keys. :param resource_group_name: The name of the resource group. @@ -488,14 +560,19 @@ async def list_keys( :type gateway_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GatewayKeysContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayKeysContract + :rtype: ~azure.mgmt.apimanagement.models.GatewayKeysContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayKeysContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayKeysContract] request = build_list_keys_request( @@ -503,12 +580,19 @@ async def list_keys( service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -526,16 +610,16 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listKeys"} # type: ignore @distributed_trace_async - async def regenerate_key( + async def regenerate_key( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, gateway_id: str, - parameters: "_models.GatewayKeyRegenerationRequestContract", + parameters: _models.GatewayKeyRegenerationRequestContract, **kwargs: Any ) -> None: """Regenerates specified gateway key invalidating any tokens created with it. @@ -548,19 +632,23 @@ async def regenerate_key( service instance. Must not have value 'managed'. :type gateway_id: str :param parameters: - :type parameters: ~api_management_client.models.GatewayKeyRegenerationRequestContract + :type parameters: ~azure.mgmt.apimanagement.models.GatewayKeyRegenerationRequestContract :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(parameters, 'GatewayKeyRegenerationRequestContract') @@ -569,14 +657,21 @@ async def regenerate_key( service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -587,7 +682,7 @@ async def regenerate_key( if cls: return cls(pipeline_response, None, {}) - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/regenerateKey"} # type: ignore @distributed_trace_async @@ -596,9 +691,9 @@ async def generate_token( resource_group_name: str, service_name: str, gateway_id: str, - parameters: "_models.GatewayTokenRequestContract", + parameters: _models.GatewayTokenRequestContract, **kwargs: Any - ) -> "_models.GatewayTokenContract": + ) -> _models.GatewayTokenContract: """Gets the Shared Access Authorization Token for the gateway. :param resource_group_name: The name of the resource group. @@ -609,19 +704,23 @@ async def generate_token( service instance. Must not have value 'managed'. :type gateway_id: str :param parameters: - :type parameters: ~api_management_client.models.GatewayTokenRequestContract + :type parameters: ~azure.mgmt.apimanagement.models.GatewayTokenRequestContract :keyword callable cls: A custom type or function that will be passed the direct response :return: GatewayTokenContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayTokenContract + :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayTokenContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayTokenContract] _json = self._serialize.body(parameters, 'GatewayTokenRequestContract') @@ -630,14 +729,21 @@ async def generate_token( service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.generate_token.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -652,5 +758,5 @@ async def generate_token( return deserialized - generate_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/generateToken'} # type: ignore + generate_token.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/generateToken"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_global_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_global_schema_operations.py index 936b21136c7a..48b9d4e46275 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_global_schema_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_global_schema_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,36 +16,36 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request from ...operations._global_schema_operations import build_create_or_update_request_initial, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GlobalSchemaOperations: - """GlobalSchemaOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`global_schema` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -57,7 +56,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.GlobalSchemaCollection"]: + ) -> AsyncIterable[_models.GlobalSchemaCollection]: """Lists a collection of schemas registered with service instance. :param resource_group_name: The name of the resource group. @@ -66,24 +65,30 @@ def list_by_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 |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GlobalSchemaCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.GlobalSchemaCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GlobalSchemaCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GlobalSchemaCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GlobalSchemaCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -91,13 +96,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -105,13 +113,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -125,7 +136,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,7 +154,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -163,11 +178,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -175,12 +195,19 @@ async def get_entity_tag( service_name=service_name, schema_id=schema_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -196,7 +223,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # type: ignore @distributed_trace_async @@ -206,7 +233,7 @@ async def get( service_name: str, schema_id: str, **kwargs: Any - ) -> "_models.GlobalSchemaContract": + ) -> _models.GlobalSchemaContract: """Gets the details of the Schema specified by its identifier. :param resource_group_name: The name of the resource group. @@ -218,14 +245,19 @@ async def get( :type schema_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GlobalSchemaContract, or the result of cls(response) - :rtype: ~api_management_client.models.GlobalSchemaContract + :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GlobalSchemaContract] request = build_get_request( @@ -233,12 +265,19 @@ async def get( service_name=service_name, schema_id=schema_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -256,7 +295,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # type: ignore async def _create_or_update_initial( @@ -264,17 +303,21 @@ async def _create_or_update_initial( resource_group_name: str, service_name: str, schema_id: str, - parameters: "_models.GlobalSchemaContract", + parameters: _models.GlobalSchemaContract, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.GlobalSchemaContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GlobalSchemaContract"]] + ) -> Optional[_models.GlobalSchemaContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.GlobalSchemaContract]] _json = self._serialize.body(parameters, 'GlobalSchemaContract') @@ -283,15 +326,22 @@ async def _create_or_update_initial( service_name=service_name, schema_id=schema_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -315,7 +365,7 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # type: ignore @distributed_trace_async @@ -324,10 +374,10 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, schema_id: str, - parameters: "_models.GlobalSchemaContract", + parameters: _models.GlobalSchemaContract, if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.GlobalSchemaContract"]: + ) -> AsyncLROPoller[_models.GlobalSchemaContract]: """Creates new or updates existing specified Schema of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -338,9 +388,9 @@ async def begin_create_or_update( instance. :type schema_id: str :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.GlobalSchemaContract + :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. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -352,26 +402,34 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either GlobalSchemaContract or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~api_management_client.models.GlobalSchemaContract] + :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"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GlobalSchemaContract] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, schema_id=schema_id, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -387,8 +445,14 @@ def get_long_running_output(pipeline_response): 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() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -397,13 +461,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -428,11 +491,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -440,13 +508,20 @@ async def delete( service_name=service_name, schema_id=schema_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -457,5 +532,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_operations.py index 6e5205129cf0..cbbf681bffc3 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._group_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GroupOperations: - """GroupOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`group` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -55,7 +54,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.GroupCollection"]: + ) -> AsyncIterable[_models.GroupCollection]: """Lists a collection of groups defined within a service instance. :param resource_group_name: The name of the resource group. @@ -67,22 +66,28 @@ def list_by_service( filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| externalId | filter | eq | |
. + endswith |
| externalId | filter | eq | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GroupCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.GroupCollection] + :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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GroupCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -90,13 +95,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -104,13 +112,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,7 +135,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -138,7 +153,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -162,11 +177,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -174,12 +194,19 @@ async def get_entity_tag( service_name=service_name, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -195,7 +222,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # type: ignore @distributed_trace_async @@ -205,7 +232,7 @@ async def get( service_name: str, group_id: str, **kwargs: Any - ) -> "_models.GroupContract": + ) -> _models.GroupContract: """Gets the details of the group specified by its identifier. :param resource_group_name: The name of the resource group. @@ -217,14 +244,19 @@ async def get( :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GroupContract, or the result of cls(response) - :rtype: ~api_management_client.models.GroupContract + :rtype: ~azure.mgmt.apimanagement.models.GroupContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GroupContract] request = build_get_request( @@ -232,12 +264,19 @@ async def get( service_name=service_name, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -255,7 +294,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # type: ignore @distributed_trace_async @@ -264,10 +303,10 @@ async def create_or_update( resource_group_name: str, service_name: str, group_id: str, - parameters: "_models.GroupCreateParameters", + parameters: _models.GroupCreateParameters, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.GroupContract": + ) -> _models.GroupContract: """Creates or Updates a group. :param resource_group_name: The name of the resource group. @@ -278,22 +317,26 @@ async def create_or_update( instance. :type group_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.GroupCreateParameters + :type parameters: ~azure.mgmt.apimanagement.models.GroupCreateParameters :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GroupContract, or the result of cls(response) - :rtype: ~api_management_client.models.GroupContract + :rtype: ~azure.mgmt.apimanagement.models.GroupContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GroupContract] _json = self._serialize.body(parameters, 'GroupCreateParameters') @@ -302,15 +345,22 @@ async def create_or_update( service_name=service_name, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -334,7 +384,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # type: ignore @distributed_trace_async @@ -344,9 +394,9 @@ async def update( service_name: str, group_id: str, if_match: str, - parameters: "_models.GroupUpdateParameters", + parameters: _models.GroupUpdateParameters, **kwargs: Any - ) -> "_models.GroupContract": + ) -> _models.GroupContract: """Updates the details of the group specified by its identifier. :param resource_group_name: The name of the resource group. @@ -360,19 +410,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.GroupUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.GroupUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: GroupContract, or the result of cls(response) - :rtype: ~api_management_client.models.GroupContract + :rtype: ~azure.mgmt.apimanagement.models.GroupContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GroupContract] _json = self._serialize.body(parameters, 'GroupUpdateParameters') @@ -381,15 +435,22 @@ async def update( service_name=service_name, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,11 +468,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -436,11 +497,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -448,13 +514,20 @@ async def delete( service_name=service_name, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -465,5 +538,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_user_operations.py index b56c43212553..04b03ec8425f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_user_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_user_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._group_user_operations import build_check_entity_exists_request, build_create_request, build_delete_request, build_list_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GroupUserOperations: - """GroupUserOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`group_user` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -56,7 +55,7 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.UserCollection"]: + ) -> AsyncIterable[_models.UserCollection]: """Lists a collection of user entities associated with the group. :param resource_group_name: The name of the resource group. @@ -73,22 +72,28 @@ def list( lastName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| email | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| registrationDate | filter | ge, le, eq, ne, gt, lt | |
| note | filter | ge, - le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either UserCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.UserCollection] + :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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -97,13 +102,16 @@ def prepare_request(next_link=None): service_name=service_name, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -112,13 +120,16 @@ def prepare_request(next_link=None): service_name=service_name, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -132,7 +143,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,7 +161,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users"} # type: ignore @distributed_trace_async async def check_entity_exists( @@ -173,11 +188,16 @@ async def check_entity_exists( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_check_entity_exists_request( @@ -186,12 +206,19 @@ async def check_entity_exists( group_id=group_id, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.check_entity_exists.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -203,7 +230,7 @@ async def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} # type: ignore + check_entity_exists.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}"} # type: ignore @distributed_trace_async @@ -214,7 +241,7 @@ async def create( group_id: str, user_id: str, **kwargs: Any - ) -> "_models.UserContract": + ) -> _models.UserContract: """Add existing user to existing group. :param resource_group_name: The name of the resource group. @@ -228,14 +255,19 @@ async def create( :type user_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: UserContract, or the result of cls(response) - :rtype: ~api_management_client.models.UserContract + :rtype: ~azure.mgmt.apimanagement.models.UserContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserContract] request = build_create_request( @@ -244,12 +276,19 @@ async def create( group_id=group_id, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -268,11 +307,11 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -296,11 +335,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -309,12 +353,19 @@ async def delete( group_id=group_id, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -325,5 +376,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_identity_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_identity_provider_operations.py index de7c1908612d..be21452e47a5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_identity_provider_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_identity_provider_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._identity_provider_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_list_secrets_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class IdentityProviderOperations: - """IdentityProviderOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`identity_provider` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -52,7 +51,7 @@ def list_by_service( resource_group_name: str, service_name: str, **kwargs: Any - ) -> AsyncIterable["_models.IdentityProviderList"]: + ) -> AsyncIterable[_models.IdentityProviderList]: """Lists a collection of Identity Provider configured in the specified service instance. :param resource_group_name: The name of the resource group. @@ -63,14 +62,19 @@ def list_by_service( :return: An iterator like instance of either IdentityProviderList or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.IdentityProviderList] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IdentityProviderList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IdentityProviderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IdentityProviderList] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -78,10 +82,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -89,10 +96,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -106,7 +116,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -120,7 +134,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -137,17 +151,22 @@ async def get_entity_tag( :param service_name: The name of the API Management service. :type service_name: str :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType :keyword callable cls: A custom type or function that will be passed the direct response :return: bool, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -155,12 +174,19 @@ async def get_entity_tag( service_name=service_name, identity_provider_name=identity_provider_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -176,7 +202,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # type: ignore @distributed_trace_async @@ -186,7 +212,7 @@ async def get( service_name: str, identity_provider_name: Union[str, "_models.IdentityProviderType"], **kwargs: Any - ) -> "_models.IdentityProviderContract": + ) -> _models.IdentityProviderContract: """Gets the configuration details of the identity Provider configured in specified service instance. @@ -195,17 +221,22 @@ async def get( :param service_name: The name of the API Management service. :type service_name: str :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType :keyword callable cls: A custom type or function that will be passed the direct response :return: IdentityProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.IdentityProviderContract + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IdentityProviderContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IdentityProviderContract] request = build_get_request( @@ -213,12 +244,19 @@ async def get( service_name=service_name, identity_provider_name=identity_provider_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -236,7 +274,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # type: ignore @distributed_trace_async @@ -245,10 +283,10 @@ async def create_or_update( resource_group_name: str, service_name: str, identity_provider_name: Union[str, "_models.IdentityProviderType"], - parameters: "_models.IdentityProviderCreateContract", + parameters: _models.IdentityProviderCreateContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IdentityProviderContract": + ) -> _models.IdentityProviderContract: """Creates or Updates the IdentityProvider configuration. :param resource_group_name: The name of the resource group. @@ -256,24 +294,28 @@ async def create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType :param parameters: Create parameters. - :type parameters: ~api_management_client.models.IdentityProviderCreateContract + :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderCreateContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: IdentityProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.IdentityProviderContract + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IdentityProviderContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.IdentityProviderContract] _json = self._serialize.body(parameters, 'IdentityProviderCreateContract') @@ -282,15 +324,22 @@ async def create_or_update( service_name=service_name, identity_provider_name=identity_provider_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -314,7 +363,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # type: ignore @distributed_trace_async @@ -324,9 +373,9 @@ async def update( service_name: str, identity_provider_name: Union[str, "_models.IdentityProviderType"], if_match: str, - parameters: "_models.IdentityProviderUpdateParameters", + parameters: _models.IdentityProviderUpdateParameters, **kwargs: Any - ) -> "_models.IdentityProviderContract": + ) -> _models.IdentityProviderContract: """Updates an existing IdentityProvider configuration. :param resource_group_name: The name of the resource group. @@ -334,24 +383,28 @@ async def update( :param service_name: The name of the API Management service. :type service_name: str :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.IdentityProviderUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: IdentityProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.IdentityProviderContract + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IdentityProviderContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.IdentityProviderContract] _json = self._serialize.body(parameters, 'IdentityProviderUpdateParameters') @@ -360,15 +413,22 @@ async def update( service_name=service_name, identity_provider_name=identity_provider_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -386,11 +446,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -405,7 +465,7 @@ async def delete( :param service_name: The name of the API Management service. :type service_name: str :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str @@ -414,11 +474,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -426,13 +491,20 @@ async def delete( service_name=service_name, identity_provider_name=identity_provider_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -443,7 +515,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # type: ignore @distributed_trace_async @@ -453,7 +525,7 @@ async def list_secrets( service_name: str, identity_provider_name: Union[str, "_models.IdentityProviderType"], **kwargs: Any - ) -> "_models.ClientSecretContract": + ) -> _models.ClientSecretContract: """Gets the client secret details of the Identity Provider. :param resource_group_name: The name of the resource group. @@ -461,17 +533,22 @@ async def list_secrets( :param service_name: The name of the API Management service. :type service_name: str :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType :keyword callable cls: A custom type or function that will be passed the direct response :return: ClientSecretContract, or the result of cls(response) - :rtype: ~api_management_client.models.ClientSecretContract + :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClientSecretContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ClientSecretContract] request = build_list_secrets_request( @@ -479,12 +556,19 @@ async def list_secrets( service_name=service_name, identity_provider_name=identity_provider_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_secrets.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -502,5 +586,5 @@ async def list_secrets( return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}/listSecrets'} # type: ignore + list_secrets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_issue_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_issue_operations.py index c98e6d620436..dc6158e59fa1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_issue_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_issue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._issue_operations import build_get_request, build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class IssueOperations: - """IssueOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`issue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -55,7 +54,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.IssueCollection"]: + ) -> AsyncIterable[_models.IssueCollection]: """Lists a collection of issues in the specified service instance. :param resource_group_name: The name of the resource group. @@ -69,22 +68,28 @@ def list_by_service( filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| authorName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| state | filter | eq | |
. + endswith |
| state | filter | eq | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either IssueCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.IssueCollection] + :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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -92,13 +97,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -106,13 +114,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,7 +137,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -140,7 +155,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues"} # type: ignore @distributed_trace_async async def get( @@ -149,7 +164,7 @@ async def get( service_name: str, issue_id: str, **kwargs: Any - ) -> "_models.IssueContract": + ) -> _models.IssueContract: """Gets API Management issue details. :param resource_group_name: The name of the resource group. @@ -161,14 +176,19 @@ async def get( :type issue_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: IssueContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueContract + :rtype: ~azure.mgmt.apimanagement.models.IssueContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueContract] request = build_get_request( @@ -176,12 +196,19 @@ async def get( service_name=service_name, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -199,5 +226,5 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues/{issueId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues/{issueId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_logger_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_logger_operations.py index 3de82e8a7bc0..66c1ed9ccb3f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_logger_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_logger_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._logger_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LoggerOperations: - """LoggerOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`logger` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -55,7 +54,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.LoggerCollection"]: + ) -> AsyncIterable[_models.LoggerCollection]: """Lists a collection of loggers in the specified service instance. :param resource_group_name: The name of the resource group. @@ -67,22 +66,28 @@ def list_by_service( filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| loggerType | filter | eq | |
| resourceId | filter | ge, le, eq, ne, gt, lt | - substringof, contains, startswith, endswith |
. + substringof, contains, startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LoggerCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.LoggerCollection] + :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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LoggerCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -90,13 +95,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -104,13 +112,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,7 +135,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -138,7 +153,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -161,11 +176,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -173,12 +193,19 @@ async def get_entity_tag( service_name=service_name, logger_id=logger_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -194,7 +221,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # type: ignore @distributed_trace_async @@ -204,7 +231,7 @@ async def get( service_name: str, logger_id: str, **kwargs: Any - ) -> "_models.LoggerContract": + ) -> _models.LoggerContract: """Gets the details of the logger specified by its identifier. :param resource_group_name: The name of the resource group. @@ -215,14 +242,19 @@ async def get( :type logger_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LoggerContract, or the result of cls(response) - :rtype: ~api_management_client.models.LoggerContract + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LoggerContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LoggerContract] request = build_get_request( @@ -230,12 +262,19 @@ async def get( service_name=service_name, logger_id=logger_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -253,7 +292,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # type: ignore @distributed_trace_async @@ -262,10 +301,10 @@ async def create_or_update( resource_group_name: str, service_name: str, logger_id: str, - parameters: "_models.LoggerContract", + parameters: _models.LoggerContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.LoggerContract": + ) -> _models.LoggerContract: """Creates or Updates a logger. :param resource_group_name: The name of the resource group. @@ -275,22 +314,26 @@ async def create_or_update( :param logger_id: Logger identifier. Must be unique in the API Management service instance. :type logger_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.LoggerContract + :type parameters: ~azure.mgmt.apimanagement.models.LoggerContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LoggerContract, or the result of cls(response) - :rtype: ~api_management_client.models.LoggerContract + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LoggerContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LoggerContract] _json = self._serialize.body(parameters, 'LoggerContract') @@ -299,15 +342,22 @@ async def create_or_update( service_name=service_name, logger_id=logger_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -331,7 +381,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # type: ignore @distributed_trace_async @@ -341,9 +391,9 @@ async def update( service_name: str, logger_id: str, if_match: str, - parameters: "_models.LoggerUpdateContract", + parameters: _models.LoggerUpdateContract, **kwargs: Any - ) -> "_models.LoggerContract": + ) -> _models.LoggerContract: """Updates an existing logger. :param resource_group_name: The name of the resource group. @@ -356,19 +406,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.LoggerUpdateContract + :type parameters: ~azure.mgmt.apimanagement.models.LoggerUpdateContract :keyword callable cls: A custom type or function that will be passed the direct response :return: LoggerContract, or the result of cls(response) - :rtype: ~api_management_client.models.LoggerContract + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LoggerContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LoggerContract] _json = self._serialize.body(parameters, 'LoggerUpdateContract') @@ -377,15 +431,22 @@ async def update( service_name=service_name, logger_id=logger_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -403,11 +464,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -431,11 +492,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -443,13 +509,20 @@ async def delete( service_name=service_name, logger_id=logger_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -460,5 +533,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_named_value_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_named_value_operations.py index 32e37b7e7354..5b477473e621 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_named_value_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_named_value_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,36 +16,36 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request from ...operations._named_value_operations import build_create_or_update_request_initial, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_list_value_request, build_refresh_secret_request_initial, build_update_request_initial +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class NamedValueOperations: - """NamedValueOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`named_value` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -58,7 +57,7 @@ def list_by_service( skip: Optional[int] = None, is_key_vault_refresh_failed: Optional[bool] = None, **kwargs: Any - ) -> AsyncIterable["_models.NamedValueCollection"]: + ) -> AsyncIterable[_models.NamedValueCollection]: """Lists a collection of named values defined within a service instance. :param resource_group_name: The name of the resource group. @@ -69,27 +68,32 @@ def list_by_service( functions |
|-------------|-------------|-------------|-------------|
| tags | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith, any, all |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
. + |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :param is_key_vault_refresh_failed: When set to true, the response contains only named value - entities which failed refresh. + entities which failed refresh. Default value is None. :type is_key_vault_refresh_failed: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either NamedValueCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.NamedValueCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.NamedValueCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NamedValueCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -97,14 +101,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, is_key_vault_refresh_failed=is_key_vault_refresh_failed, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -112,14 +119,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, is_key_vault_refresh_failed=is_key_vault_refresh_failed, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -133,7 +143,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,7 +161,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -170,11 +184,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -182,12 +201,19 @@ async def get_entity_tag( service_name=service_name, named_value_id=named_value_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -203,7 +229,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore @distributed_trace_async @@ -213,7 +239,7 @@ async def get( service_name: str, named_value_id: str, **kwargs: Any - ) -> "_models.NamedValueContract": + ) -> _models.NamedValueContract: """Gets the details of the named value specified by its identifier. :param resource_group_name: The name of the resource group. @@ -224,14 +250,19 @@ async def get( :type named_value_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: NamedValueContract, or the result of cls(response) - :rtype: ~api_management_client.models.NamedValueContract + :rtype: ~azure.mgmt.apimanagement.models.NamedValueContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NamedValueContract] request = build_get_request( @@ -239,12 +270,19 @@ async def get( service_name=service_name, named_value_id=named_value_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -262,7 +300,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore async def _create_or_update_initial( @@ -270,17 +308,21 @@ async def _create_or_update_initial( resource_group_name: str, service_name: str, named_value_id: str, - parameters: "_models.NamedValueCreateContract", + parameters: _models.NamedValueCreateContract, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.NamedValueContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.NamedValueContract"]] + ) -> Optional[_models.NamedValueContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.NamedValueContract]] _json = self._serialize.body(parameters, 'NamedValueCreateContract') @@ -289,15 +331,22 @@ async def _create_or_update_initial( service_name=service_name, named_value_id=named_value_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -321,7 +370,7 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore @distributed_trace_async @@ -330,10 +379,10 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, named_value_id: str, - parameters: "_models.NamedValueCreateContract", + parameters: _models.NamedValueCreateContract, if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.NamedValueContract"]: + ) -> AsyncLROPoller[_models.NamedValueContract]: """Creates or updates named value. :param resource_group_name: The name of the resource group. @@ -343,9 +392,9 @@ async def begin_create_or_update( :param named_value_id: Identifier of the NamedValue. :type named_value_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.NamedValueCreateContract + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueCreateContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -357,26 +406,33 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either NamedValueContract or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~api_management_client.models.NamedValueContract] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueContract"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.NamedValueContract] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, named_value_id=named_value_id, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -392,8 +448,14 @@ def get_long_running_output(pipeline_response): 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() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -402,10 +464,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore async def _update_initial( self, @@ -413,16 +474,20 @@ async def _update_initial( service_name: str, named_value_id: str, if_match: str, - parameters: "_models.NamedValueUpdateParameters", + parameters: _models.NamedValueUpdateParameters, **kwargs: Any - ) -> Optional["_models.NamedValueContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.NamedValueContract"]] + ) -> Optional[_models.NamedValueContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.NamedValueContract]] _json = self._serialize.body(parameters, 'NamedValueUpdateParameters') @@ -431,15 +496,22 @@ async def _update_initial( service_name=service_name, named_value_id=named_value_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -458,7 +530,7 @@ async def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore @distributed_trace_async @@ -468,9 +540,9 @@ async def begin_update( service_name: str, named_value_id: str, if_match: str, - parameters: "_models.NamedValueUpdateParameters", + parameters: _models.NamedValueUpdateParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.NamedValueContract"]: + ) -> AsyncLROPoller[_models.NamedValueContract]: """Updates the specific named value. :param resource_group_name: The name of the resource group. @@ -483,7 +555,7 @@ async def begin_update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.NamedValueUpdateParameters + :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 @@ -494,26 +566,33 @@ async def begin_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either NamedValueContract or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~api_management_client.models.NamedValueContract] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueContract"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.NamedValueContract] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, named_value_id=named_value_id, if_match=if_match, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -529,8 +608,14 @@ def get_long_running_output(pipeline_response): 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() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -539,13 +624,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -569,11 +653,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -581,13 +670,20 @@ async def delete( service_name=service_name, named_value_id=named_value_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -598,7 +694,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore @distributed_trace_async @@ -608,7 +704,7 @@ async def list_value( service_name: str, named_value_id: str, **kwargs: Any - ) -> "_models.NamedValueSecretContract": + ) -> _models.NamedValueSecretContract: """Gets the secret of the named value specified by its identifier. :param resource_group_name: The name of the resource group. @@ -619,14 +715,19 @@ async def list_value( :type named_value_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: NamedValueSecretContract, or the result of cls(response) - :rtype: ~api_management_client.models.NamedValueSecretContract + :rtype: ~azure.mgmt.apimanagement.models.NamedValueSecretContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueSecretContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NamedValueSecretContract] request = build_list_value_request( @@ -634,12 +735,19 @@ async def list_value( service_name=service_name, named_value_id=named_value_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_value.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -657,7 +765,7 @@ async def list_value( return deserialized - list_value.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/listValue'} # type: ignore + list_value.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/listValue"} # type: ignore async def _refresh_secret_initial( @@ -666,12 +774,17 @@ async def _refresh_secret_initial( service_name: str, named_value_id: str, **kwargs: Any - ) -> Optional["_models.NamedValueContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.NamedValueContract"]] + ) -> Optional[_models.NamedValueContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.NamedValueContract]] request = build_refresh_secret_request_initial( @@ -679,12 +792,19 @@ async def _refresh_secret_initial( service_name=service_name, named_value_id=named_value_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._refresh_secret_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -703,7 +823,7 @@ async def _refresh_secret_initial( return deserialized - _refresh_secret_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret'} # type: ignore + _refresh_secret_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret"} # type: ignore @distributed_trace_async @@ -713,7 +833,7 @@ async def begin_refresh_secret( service_name: str, named_value_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.NamedValueContract"]: + ) -> AsyncLROPoller[_models.NamedValueContract]: """Refresh the secret of the named value specified by its identifier. :param resource_group_name: The name of the resource group. @@ -732,22 +852,29 @@ async def begin_refresh_secret( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either NamedValueContract or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~api_management_client.models.NamedValueContract] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueContract"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NamedValueContract] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._refresh_secret_initial( + raw_result = await self._refresh_secret_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, named_value_id=named_value_id, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -763,8 +890,14 @@ def get_long_running_output(pipeline_response): 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() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -773,7 +906,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh_secret.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret'} # type: ignore + begin_refresh_secret.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_network_status_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_network_status_operations.py index 37ccbb58477f..25abcdd89015 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_network_status_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_network_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,44 +6,42 @@ # 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 typing import Any, Callable, Dict, List, Optional, TypeVar 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._network_status_operations import build_list_by_location_request, build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class NetworkStatusOperations: - """NetworkStatusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`network_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_service( @@ -50,7 +49,7 @@ async def list_by_service( resource_group_name: str, service_name: str, **kwargs: Any - ) -> List["_models.NetworkStatusContractByLocation"]: + ) -> 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. @@ -61,26 +60,38 @@ async def list_by_service( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: list of NetworkStatusContractByLocation, or the result of cls(response) - :rtype: list[~api_management_client.models.NetworkStatusContractByLocation] + :rtype: list[~azure.mgmt.apimanagement.models.NetworkStatusContractByLocation] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.NetworkStatusContractByLocation"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.NetworkStatusContractByLocation]] request = build_list_by_service_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +106,7 @@ async def list_by_service( return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus"} # type: ignore @distributed_trace_async @@ -105,7 +116,7 @@ async def list_by_location( service_name: str, location_name: str, **kwargs: Any - ) -> "_models.NetworkStatusContract": + ) -> _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. @@ -119,14 +130,19 @@ async def list_by_location( :type location_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: NetworkStatusContract, or the result of cls(response) - :rtype: ~api_management_client.models.NetworkStatusContract + :rtype: ~azure.mgmt.apimanagement.models.NetworkStatusContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkStatusContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkStatusContract] request = build_list_by_location_request( @@ -134,12 +150,19 @@ async def list_by_location( resource_group_name=resource_group_name, service_name=service_name, location_name=location_name, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -154,5 +177,5 @@ async def list_by_location( return deserialized - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/locations/{locationName}/networkstatus'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/locations/{locationName}/networkstatus"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_operations.py index 75eea4d6b3d6..c24624643814 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._notification_operations import build_create_or_update_request, build_get_request, build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class NotificationOperations: - """NotificationOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`notification` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -54,29 +53,34 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.NotificationCollection"]: + ) -> AsyncIterable[_models.NotificationCollection]: """Lists a collection of properties defined within a 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 top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either NotificationCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.NotificationCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.NotificationCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NotificationCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NotificationCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -84,12 +88,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -97,12 +104,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -116,7 +126,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -130,7 +144,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications"} # type: ignore @distributed_trace_async async def get( @@ -139,7 +153,7 @@ async def get( service_name: str, notification_name: Union[str, "_models.NotificationName"], **kwargs: Any - ) -> "_models.NotificationContract": + ) -> _models.NotificationContract: """Gets the details of the Notification specified by its identifier. :param resource_group_name: The name of the resource group. @@ -147,17 +161,22 @@ async def get( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :keyword callable cls: A custom type or function that will be passed the direct response :return: NotificationContract, or the result of cls(response) - :rtype: ~api_management_client.models.NotificationContract + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NotificationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NotificationContract] request = build_get_request( @@ -165,12 +184,19 @@ async def get( service_name=service_name, notification_name=notification_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -185,7 +211,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}"} # type: ignore @distributed_trace_async @@ -196,7 +222,7 @@ async def create_or_update( notification_name: Union[str, "_models.NotificationName"], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.NotificationContract": + ) -> _models.NotificationContract: """Create or Update API Management publisher notification. :param resource_group_name: The name of the resource group. @@ -204,20 +230,25 @@ async def create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: NotificationContract, or the result of cls(response) - :rtype: ~api_management_client.models.NotificationContract + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NotificationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NotificationContract] request = build_create_or_update_request( @@ -225,13 +256,20 @@ async def create_or_update( service_name=service_name, notification_name=notification_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -246,5 +284,5 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_email_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_email_operations.py index f0cf5318d950..2e7dc4260fc0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_email_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_email_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,44 +6,42 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._notification_recipient_email_operations import build_check_entity_exists_request, build_create_or_update_request, build_delete_request, build_list_by_notification_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class NotificationRecipientEmailOperations: - """NotificationRecipientEmailOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`notification_recipient_email` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_notification( @@ -51,7 +50,7 @@ async def list_by_notification( service_name: str, notification_name: Union[str, "_models.NotificationName"], **kwargs: Any - ) -> "_models.RecipientEmailCollection": + ) -> _models.RecipientEmailCollection: """Gets the list of the Notification Recipient Emails subscribed to a notification. :param resource_group_name: The name of the resource group. @@ -59,17 +58,22 @@ async def list_by_notification( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :keyword callable cls: A custom type or function that will be passed the direct response :return: RecipientEmailCollection, or the result of cls(response) - :rtype: ~api_management_client.models.RecipientEmailCollection + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecipientEmailCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecipientEmailCollection] request = build_list_by_notification_request( @@ -77,12 +81,19 @@ async def list_by_notification( service_name=service_name, notification_name=notification_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_notification.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -97,7 +108,7 @@ async def list_by_notification( return deserialized - list_by_notification.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails'} # type: ignore + list_by_notification.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails"} # type: ignore @distributed_trace_async @@ -116,7 +127,7 @@ async def check_entity_exists( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :param email: Email identifier. :type email: str :keyword callable cls: A custom type or function that will be passed the direct response @@ -124,11 +135,16 @@ async def check_entity_exists( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_check_entity_exists_request( @@ -137,12 +153,19 @@ async def check_entity_exists( notification_name=notification_name, email=email, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.check_entity_exists.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -154,7 +177,7 @@ async def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} # type: ignore + check_entity_exists.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}"} # type: ignore @distributed_trace_async @@ -165,7 +188,7 @@ async def create_or_update( notification_name: Union[str, "_models.NotificationName"], email: str, **kwargs: Any - ) -> "_models.RecipientEmailContract": + ) -> _models.RecipientEmailContract: """Adds the Email address to the list of Recipients for the Notification. :param resource_group_name: The name of the resource group. @@ -173,19 +196,24 @@ async def create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :param email: Email identifier. :type email: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RecipientEmailContract, or the result of cls(response) - :rtype: ~api_management_client.models.RecipientEmailContract + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecipientEmailContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecipientEmailContract] request = build_create_or_update_request( @@ -194,12 +222,19 @@ async def create_or_update( notification_name=notification_name, email=email, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -218,11 +253,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -237,7 +272,7 @@ async def delete( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :param email: Email identifier. :type email: str :keyword callable cls: A custom type or function that will be passed the direct response @@ -245,11 +280,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -258,12 +298,19 @@ async def delete( notification_name=notification_name, email=email, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,5 +321,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_user_operations.py index f62941b881f8..39dd1e5bd02f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_user_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_user_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,44 +6,42 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._notification_recipient_user_operations import build_check_entity_exists_request, build_create_or_update_request, build_delete_request, build_list_by_notification_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class NotificationRecipientUserOperations: - """NotificationRecipientUserOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`notification_recipient_user` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_notification( @@ -51,7 +50,7 @@ async def list_by_notification( service_name: str, notification_name: Union[str, "_models.NotificationName"], **kwargs: Any - ) -> "_models.RecipientUserCollection": + ) -> _models.RecipientUserCollection: """Gets the list of the Notification Recipient User subscribed to the notification. :param resource_group_name: The name of the resource group. @@ -59,17 +58,22 @@ async def list_by_notification( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :keyword callable cls: A custom type or function that will be passed the direct response :return: RecipientUserCollection, or the result of cls(response) - :rtype: ~api_management_client.models.RecipientUserCollection + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecipientUserCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecipientUserCollection] request = build_list_by_notification_request( @@ -77,12 +81,19 @@ async def list_by_notification( service_name=service_name, notification_name=notification_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_notification.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -97,7 +108,7 @@ async def list_by_notification( return deserialized - list_by_notification.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers'} # type: ignore + list_by_notification.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers"} # type: ignore @distributed_trace_async @@ -116,7 +127,7 @@ async def check_entity_exists( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str :keyword callable cls: A custom type or function that will be passed the direct response @@ -124,11 +135,16 @@ async def check_entity_exists( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_check_entity_exists_request( @@ -137,12 +153,19 @@ async def check_entity_exists( notification_name=notification_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.check_entity_exists.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -154,7 +177,7 @@ async def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} # type: ignore + check_entity_exists.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}"} # type: ignore @distributed_trace_async @@ -165,7 +188,7 @@ async def create_or_update( notification_name: Union[str, "_models.NotificationName"], user_id: str, **kwargs: Any - ) -> "_models.RecipientUserContract": + ) -> _models.RecipientUserContract: """Adds the API Management User to the list of Recipients for the Notification. :param resource_group_name: The name of the resource group. @@ -173,19 +196,24 @@ async def create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RecipientUserContract, or the result of cls(response) - :rtype: ~api_management_client.models.RecipientUserContract + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecipientUserContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecipientUserContract] request = build_create_or_update_request( @@ -194,12 +222,19 @@ async def create_or_update( notification_name=notification_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -218,11 +253,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -237,7 +272,7 @@ async def delete( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str :keyword callable cls: A custom type or function that will be passed the direct response @@ -245,11 +280,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -258,12 +298,19 @@ async def delete( notification_name=notification_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,5 +321,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_open_id_connect_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_open_id_connect_provider_operations.py index 9358f344731e..a3e612996738 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_open_id_connect_provider_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_open_id_connect_provider_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._open_id_connect_provider_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_list_secrets_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class OpenIdConnectProviderOperations: - """OpenIdConnectProviderOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`open_id_connect_provider` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -55,7 +54,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.OpenIdConnectProviderCollection"]: + ) -> AsyncIterable[_models.OpenIdConnectProviderCollection]: """Lists of all the OpenId Connect Providers. :param resource_group_name: The name of the resource group. @@ -66,24 +65,29 @@ def list_by_service( functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
. + |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OpenIdConnectProviderCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.OpenIdConnectProviderCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.OpenIdConnectProviderCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenIdConnectProviderCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OpenIdConnectProviderCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -91,13 +95,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -105,13 +112,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -125,7 +135,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,7 +153,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -162,11 +176,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -174,12 +193,19 @@ async def get_entity_tag( service_name=service_name, opid=opid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -195,7 +221,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # type: ignore @distributed_trace_async @@ -205,7 +231,7 @@ async def get( service_name: str, opid: str, **kwargs: Any - ) -> "_models.OpenidConnectProviderContract": + ) -> _models.OpenidConnectProviderContract: """Gets specific OpenID Connect Provider without secrets. :param resource_group_name: The name of the resource group. @@ -216,14 +242,19 @@ async def get( :type opid: str :keyword callable cls: A custom type or function that will be passed the direct response :return: OpenidConnectProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.OpenidConnectProviderContract + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenidConnectProviderContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OpenidConnectProviderContract] request = build_get_request( @@ -231,12 +262,19 @@ async def get( service_name=service_name, opid=opid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -254,7 +292,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # type: ignore @distributed_trace_async @@ -263,10 +301,10 @@ async def create_or_update( resource_group_name: str, service_name: str, opid: str, - parameters: "_models.OpenidConnectProviderContract", + parameters: _models.OpenidConnectProviderContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.OpenidConnectProviderContract": + ) -> _models.OpenidConnectProviderContract: """Creates or updates the OpenID Connect Provider. :param resource_group_name: The name of the resource group. @@ -276,22 +314,26 @@ async def create_or_update( :param opid: Identifier of the OpenID Connect Provider. :type opid: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.OpenidConnectProviderContract + :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: OpenidConnectProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.OpenidConnectProviderContract + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenidConnectProviderContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OpenidConnectProviderContract] _json = self._serialize.body(parameters, 'OpenidConnectProviderContract') @@ -300,15 +342,22 @@ async def create_or_update( service_name=service_name, opid=opid, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -332,7 +381,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # type: ignore @distributed_trace_async @@ -342,9 +391,9 @@ async def update( service_name: str, opid: str, if_match: str, - parameters: "_models.OpenidConnectProviderUpdateContract", + parameters: _models.OpenidConnectProviderUpdateContract, **kwargs: Any - ) -> "_models.OpenidConnectProviderContract": + ) -> _models.OpenidConnectProviderContract: """Updates the specific OpenID Connect Provider. :param resource_group_name: The name of the resource group. @@ -357,19 +406,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.OpenidConnectProviderUpdateContract + :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderUpdateContract :keyword callable cls: A custom type or function that will be passed the direct response :return: OpenidConnectProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.OpenidConnectProviderContract + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenidConnectProviderContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OpenidConnectProviderContract] _json = self._serialize.body(parameters, 'OpenidConnectProviderUpdateContract') @@ -378,15 +431,22 @@ async def update( service_name=service_name, opid=opid, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -404,11 +464,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -432,11 +492,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -444,13 +509,20 @@ async def delete( service_name=service_name, opid=opid, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -461,7 +533,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # type: ignore @distributed_trace_async @@ -471,7 +543,7 @@ async def list_secrets( service_name: str, opid: str, **kwargs: Any - ) -> "_models.ClientSecretContract": + ) -> _models.ClientSecretContract: """Gets the client secret details of the OpenID Connect Provider. :param resource_group_name: The name of the resource group. @@ -482,14 +554,19 @@ async def list_secrets( :type opid: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ClientSecretContract, or the result of cls(response) - :rtype: ~api_management_client.models.ClientSecretContract + :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClientSecretContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ClientSecretContract] request = build_list_secrets_request( @@ -497,12 +574,19 @@ async def list_secrets( service_name=service_name, opid=opid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_secrets.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -520,5 +604,5 @@ async def list_secrets( return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}/listSecrets'} # type: ignore + list_secrets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_operations.py index b37cd029b939..5c3ba4060721 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,36 +14,35 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operation_operations import build_list_by_tags_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class OperationOperations: - """OperationOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`operation` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_tags( @@ -57,7 +55,7 @@ def list_by_tags( skip: Optional[int] = None, include_not_tagged_operations: Optional[bool] = None, **kwargs: Any - ) -> AsyncIterable["_models.TagResourceCollection"]: + ) -> AsyncIterable[_models.TagResourceCollection]: """Lists a collection of operations associated with tags. :param resource_group_name: The name of the resource group. @@ -75,26 +73,31 @@ def list_by_tags( |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| method | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| urlTemplate | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
. + startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param include_not_tagged_operations: Include not tagged Operations. + :param include_not_tagged_operations: Include not tagged Operations. Default value is None. :type include_not_tagged_operations: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagResourceCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TagResourceCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagResourceCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -103,14 +106,17 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, include_not_tagged_operations=include_not_tagged_operations, template_url=self.list_by_tags.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -119,14 +125,17 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, include_not_tagged_operations=include_not_tagged_operations, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -140,7 +149,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -154,4 +167,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operationsByTags'} # type: ignore + list_by_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operationsByTags"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_outbound_network_dependencies_endpoints_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_outbound_network_dependencies_endpoints_operations.py index 38b180191350..899bc78aa30c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_outbound_network_dependencies_endpoints_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_outbound_network_dependencies_endpoints_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,44 +6,42 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._outbound_network_dependencies_endpoints_operations import build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class OutboundNetworkDependenciesEndpointsOperations: - """OutboundNetworkDependenciesEndpointsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`outbound_network_dependencies_endpoints` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_service( @@ -50,7 +49,7 @@ async def list_by_service( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.OutboundEnvironmentEndpointList": + ) -> _models.OutboundEnvironmentEndpointList: """Gets the network endpoints of all outbound dependencies of a ApiManagement service. :param resource_group_name: The name of the resource group. @@ -59,26 +58,38 @@ async def list_by_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: ~api_management_client.models.OutboundEnvironmentEndpointList + :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OutboundEnvironmentEndpointList] request = build_list_by_service_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -93,5 +104,5 @@ async def list_by_service( return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/outboundNetworkDependenciesEndpoints'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/outboundNetworkDependenciesEndpoints"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_patch.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_description_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_description_operations.py index 39b0565a0a18..193cd50202d8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_description_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_description_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,44 +6,42 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._policy_description_operations import build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PolicyDescriptionOperations: - """PolicyDescriptionOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`policy_description` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_service( @@ -51,38 +50,50 @@ async def list_by_service( service_name: str, scope: Optional[Union[str, "_models.PolicyScopeContract"]] = None, **kwargs: Any - ) -> "_models.PolicyDescriptionCollection": + ) -> _models.PolicyDescriptionCollection: """Lists all policy descriptions. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param scope: Policy scope. - :type scope: str or ~api_management_client.models.PolicyScopeContract + :param scope: Policy scope. Default value is None. + :type scope: str or ~azure.mgmt.apimanagement.models.PolicyScopeContract :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyDescriptionCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyDescriptionCollection + :rtype: ~azure.mgmt.apimanagement.models.PolicyDescriptionCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDescriptionCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyDescriptionCollection] request = build_list_by_service_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, scope=scope, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -97,5 +108,5 @@ async def list_by_service( return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyDescriptions'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyDescriptions"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_fragment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_fragment_operations.py new file mode 100644 index 000000000000..2eef5341b399 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_fragment_operations.py @@ -0,0 +1,586 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast + +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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._policy_fragment_operations import build_create_or_update_request_initial, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_list_references_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicyFragmentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`policy_fragment` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def list_by_service( + self, + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + orderby: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> _models.PolicyFragmentCollection: + """Gets all policy fragments. + + :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, orderBy | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| value | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
. Default value is None. + :type filter: str + :param orderby: OData order by query option. Default value is None. + :type orderby: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyFragmentCollection, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyFragmentCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyFragmentCollection] + + + request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + orderby=orderby, + top=top, + skip=skip, + template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=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('PolicyFragmentCollection', 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}/policyFragments"} # type: ignore + + + @distributed_trace_async + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + id: str, + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of a policy fragment. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param id: A resource identifier. + :type 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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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}/policyFragments/{id}"} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + id: str, + format: Optional[Union[str, "_models.PolicyFragmentContentFormat"]] = None, + **kwargs: Any + ) -> _models.PolicyFragmentContract: + """Gets a policy fragment. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param id: A resource identifier. + :type id: str + :param format: Policy fragment content format. Default value is None. + :type format: str or ~azure.mgmt.apimanagement.models.PolicyFragmentContentFormat + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyFragmentContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyFragmentContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyFragmentContract] + + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + format=format, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('PolicyFragmentContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyFragments/{id}"} # type: ignore + + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + id: str, + parameters: _models.PolicyFragmentContract, + if_match: Optional[str] = None, + **kwargs: Any + ) -> Optional[_models.PolicyFragmentContract]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PolicyFragmentContract]] + + _json = self._serialize.body(parameters, 'PolicyFragmentContract') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 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('PolicyFragmentContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('PolicyFragmentContract', 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}/policyFragments/{id}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + id: str, + parameters: _models.PolicyFragmentContract, + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.PolicyFragmentContract]: + """Creates or updates a policy fragment. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param id: A resource identifier. + :type id: str + :param parameters: The policy fragment contents to apply. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyFragmentContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword 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 PolicyFragmentContract or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PolicyFragmentContract] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyFragmentContract] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + 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('PolicyFragmentContract', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + 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}/policyFragments/{id}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes a policy fragment. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param id: A resource identifier. + :type id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = 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}/policyFragments/{id}"} # type: ignore + + + @distributed_trace_async + async def list_references( + self, + resource_group_name: str, + service_name: str, + id: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> _models.ResourceCollection: + """Lists policy resources that reference the policy fragment. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param id: A resource identifier. + :type id: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceCollection, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ResourceCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceCollection] + + + request = build_list_references_request( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + skip=skip, + template_url=self.list_references.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_references.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyFragments/{id}/listReferences"} # 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 730db8ebd442..e754184967ad 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,44 +6,42 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._policy_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PolicyOperations: - """PolicyOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`policy` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_service( @@ -50,7 +49,7 @@ async def list_by_service( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.PolicyCollection": + ) -> _models.PolicyCollection: """Lists all the Global Policy definitions of the Api Management service. :param resource_group_name: The name of the resource group. @@ -59,26 +58,38 @@ async def list_by_service( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyCollection + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyCollection] request = build_list_by_service_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -93,7 +104,7 @@ async def list_by_service( return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies"} # type: ignore @distributed_trace_async @@ -112,17 +123,22 @@ async def get_entity_tag( :param service_name: The name of the API Management service. :type service_name: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: bool, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -130,12 +146,19 @@ async def get_entity_tag( service_name=service_name, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -151,7 +174,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}"} # type: ignore @distributed_trace_async @@ -162,7 +185,7 @@ async def get( policy_id: Union[str, "_models.PolicyIdName"], format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Get the Global policy definition of the Api Management service. :param resource_group_name: The name of the resource group. @@ -170,19 +193,24 @@ async def get( :param service_name: The name of the API Management service. :type service_name: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param format: Policy Export Format. - :type format: str or ~api_management_client.models.PolicyExportFormat + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. Default value is "xml". + :type format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyContract] request = build_get_request( @@ -190,13 +218,20 @@ async def get( service_name=service_name, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, format=format, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,7 +249,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}"} # type: ignore @distributed_trace_async @@ -223,10 +258,10 @@ async def create_or_update( resource_group_name: str, service_name: str, policy_id: Union[str, "_models.PolicyIdName"], - parameters: "_models.PolicyContract", + parameters: _models.PolicyContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Creates or updates the global policy configuration of the Api Management service. :param resource_group_name: The name of the resource group. @@ -234,24 +269,28 @@ async def create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :param parameters: The policy contents to apply. - :type parameters: ~api_management_client.models.PolicyContract + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyContract] _json = self._serialize.body(parameters, 'PolicyContract') @@ -260,15 +299,22 @@ async def create_or_update( service_name=service_name, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -292,11 +338,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -311,7 +357,7 @@ async def delete( :param service_name: The name of the API Management service. :type service_name: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str @@ -320,11 +366,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -332,13 +383,20 @@ async def delete( service_name=service_name, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -349,5 +407,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_config_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_config_operations.py new file mode 100644 index 000000000000..8091758321b3 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_config_operations.py @@ -0,0 +1,408 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._portal_config_operations import build_create_or_update_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request +from .._vendor import MixinABC +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PortalConfigOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`portal_config` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def list_by_service( + self, + resource_group_name: str, + service_name: str, + **kwargs: Any + ) -> _models.PortalConfigCollection: + """Lists the developer portal configurations. + + :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: PortalConfigCollection, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalConfigCollection] + + + request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PortalConfigCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs"} # type: ignore + + + @distributed_trace_async + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the developer portal configuration. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param portal_config_id: Portal configuration identifier. + :type portal_config_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_get_entity_tag_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_name=service_name, + portal_config_id=portal_config_id, + api_version=api_version, + template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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}/portalconfigs/{portalConfigId}"} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + **kwargs: Any + ) -> _models.PortalConfigContract: + """Get the developer portal configuration. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param portal_config_id: Portal configuration identifier. + :type portal_config_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PortalConfigContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalConfigContract] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_name=service_name, + portal_config_id=portal_config_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('PortalConfigContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + if_match: str, + parameters: _models.PortalConfigContract, + **kwargs: Any + ) -> _models.PortalConfigContract: + """Update the developer portal configuration. + + :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 portal_config_id: Portal configuration identifier. + :type portal_config_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param parameters: Update the developer portal configuration. + :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PortalConfigContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalConfigContract] + + _json = self._serialize.body(parameters, 'PortalConfigContract') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_name=service_name, + portal_config_id=portal_config_id, + api_version=api_version, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PortalConfigContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + if_match: str, + parameters: _models.PortalConfigContract, + **kwargs: Any + ) -> _models.PortalConfigContract: + """Create or update the developer portal configuration. + + :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 portal_config_id: Portal configuration identifier. + :type portal_config_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param parameters: Update the developer portal configuration. + :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PortalConfigContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalConfigContract] + + _json = self._serialize.body(parameters, 'PortalConfigContract') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_name=service_name, + portal_config_id=portal_config_id, + api_version=api_version, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PortalConfigContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}"} # 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 fbdf3b40ab1f..98da232ed672 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_revision_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_revision_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,36 +16,36 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request from ...operations._portal_revision_operations import build_create_or_update_request_initial, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_update_request_initial +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PortalRevisionOperations: - """PortalRevisionOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`portal_revision` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -57,7 +56,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.PortalRevisionCollection"]: + ) -> AsyncIterable[_models.PortalRevisionCollection]: """Lists developer portal's revisions. :param resource_group_name: The name of the resource group. @@ -75,24 +74,29 @@ def list_by_service( |name | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith| |description | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith| - |isCurrent | eq, ne | |. + |isCurrent | eq, ne | |. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PortalRevisionCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.PortalRevisionCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PortalRevisionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalRevisionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalRevisionCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -100,13 +104,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -114,13 +121,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -134,7 +144,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -148,7 +162,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -172,11 +186,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -184,12 +203,19 @@ async def get_entity_tag( service_name=service_name, portal_revision_id=portal_revision_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -205,7 +231,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # type: ignore @distributed_trace_async @@ -215,7 +241,7 @@ async def get( service_name: str, portal_revision_id: str, **kwargs: Any - ) -> "_models.PortalRevisionContract": + ) -> _models.PortalRevisionContract: """Gets the developer portal's revision specified by its identifier. :param resource_group_name: The name of the resource group. @@ -227,14 +253,19 @@ async def get( :type portal_revision_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PortalRevisionContract, or the result of cls(response) - :rtype: ~api_management_client.models.PortalRevisionContract + :rtype: ~azure.mgmt.apimanagement.models.PortalRevisionContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalRevisionContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalRevisionContract] request = build_get_request( @@ -242,12 +273,19 @@ async def get( service_name=service_name, portal_revision_id=portal_revision_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -265,7 +303,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # type: ignore async def _create_or_update_initial( @@ -273,16 +311,20 @@ async def _create_or_update_initial( resource_group_name: str, service_name: str, portal_revision_id: str, - parameters: "_models.PortalRevisionContract", + parameters: _models.PortalRevisionContract, **kwargs: Any - ) -> Optional["_models.PortalRevisionContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PortalRevisionContract"]] + ) -> Optional[_models.PortalRevisionContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PortalRevisionContract]] _json = self._serialize.body(parameters, 'PortalRevisionContract') @@ -291,14 +333,21 @@ async def _create_or_update_initial( service_name=service_name, portal_revision_id=portal_revision_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201, 202]: @@ -317,7 +366,7 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # type: ignore @distributed_trace_async @@ -326,9 +375,9 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, portal_revision_id: str, - parameters: "_models.PortalRevisionContract", + parameters: _models.PortalRevisionContract, **kwargs: Any - ) -> AsyncLROPoller["_models.PortalRevisionContract"]: + ) -> AsyncLROPoller[_models.PortalRevisionContract]: """Creates a new developer portal's revision by running the portal's publishing. The ``isCurrent`` property indicates if the revision is publicly accessible. @@ -340,7 +389,7 @@ async def begin_create_or_update( Management service instance. :type portal_revision_id: str :param parameters: - :type parameters: ~api_management_client.models.PortalRevisionContract + :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 @@ -352,25 +401,32 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either PortalRevisionContract or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.PortalRevisionContract] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalRevisionContract"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalRevisionContract] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, portal_revision_id=portal_revision_id, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -386,8 +442,14 @@ def get_long_running_output(pipeline_response): 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() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -396,10 +458,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # type: ignore async def _update_initial( self, @@ -407,16 +468,20 @@ async def _update_initial( service_name: str, portal_revision_id: str, if_match: str, - parameters: "_models.PortalRevisionContract", + parameters: _models.PortalRevisionContract, **kwargs: Any - ) -> Optional["_models.PortalRevisionContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PortalRevisionContract"]] + ) -> Optional[_models.PortalRevisionContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PortalRevisionContract]] _json = self._serialize.body(parameters, 'PortalRevisionContract') @@ -425,15 +490,22 @@ async def _update_initial( service_name=service_name, portal_revision_id=portal_revision_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -452,7 +524,7 @@ async def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # type: ignore @distributed_trace_async @@ -462,9 +534,9 @@ async def begin_update( service_name: str, portal_revision_id: str, if_match: str, - parameters: "_models.PortalRevisionContract", + parameters: _models.PortalRevisionContract, **kwargs: Any - ) -> AsyncLROPoller["_models.PortalRevisionContract"]: + ) -> AsyncLROPoller[_models.PortalRevisionContract]: """Updates the description of specified portal revision or makes it current. :param resource_group_name: The name of the resource group. @@ -478,7 +550,7 @@ async def begin_update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: - :type parameters: ~api_management_client.models.PortalRevisionContract + :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 @@ -490,26 +562,33 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either PortalRevisionContract or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.PortalRevisionContract] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalRevisionContract"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalRevisionContract] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, portal_revision_id=portal_revision_id, if_match=if_match, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -525,8 +604,14 @@ def get_long_running_output(pipeline_response): 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() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -535,7 +620,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_settings_operations.py index cb531842816a..8ff31f6e05b7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,44 +6,42 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._portal_settings_operations import build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PortalSettingsOperations: - """PortalSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`portal_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_service( @@ -50,7 +49,7 @@ async def list_by_service( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.PortalSettingsCollection": + ) -> _models.PortalSettingsCollection: """Lists a collection of portalsettings defined within a service instance.. :param resource_group_name: The name of the resource group. @@ -59,26 +58,38 @@ async def list_by_service( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PortalSettingsCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSettingsCollection + :rtype: ~azure.mgmt.apimanagement.models.PortalSettingsCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSettingsCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalSettingsCollection] request = build_list_by_service_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -93,5 +104,5 @@ async def list_by_service( return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_private_endpoint_connection_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_private_endpoint_connection_operations.py index 85164a1dc335..583025b00352 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_private_endpoint_connection_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_private_endpoint_connection_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,36 +16,36 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request from ...operations._private_endpoint_connection_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_by_name_request, build_get_private_link_resource_request, build_list_by_service_request, build_list_private_link_resources_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateEndpointConnectionOperations: - """PrivateEndpointConnectionOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`private_endpoint_connection` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -54,7 +53,7 @@ def list_by_service( resource_group_name: str, service_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: """Lists all private endpoint connections of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -65,14 +64,19 @@ def list_by_service( :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.PrivateEndpointConnectionListResult] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -80,10 +84,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -91,10 +98,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -108,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -122,7 +136,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get_by_name( @@ -131,7 +145,7 @@ async def get_by_name( service_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the details of the Private Endpoint Connection specified by its identifier. :param resource_group_name: The name of the resource group. @@ -142,14 +156,19 @@ async def get_by_name( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection, or the result of cls(response) - :rtype: ~api_management_client.models.PrivateEndpointConnection + :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_by_name_request( @@ -157,12 +176,19 @@ async def get_by_name( service_name=service_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_by_name.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -177,7 +203,7 @@ async def get_by_name( return deserialized - get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get_by_name.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _create_or_update_initial( @@ -185,16 +211,20 @@ async def _create_or_update_initial( resource_group_name: str, service_name: str, private_endpoint_connection_name: str, - private_endpoint_connection_request: "_models.PrivateEndpointConnectionRequest", + private_endpoint_connection_request: _models.PrivateEndpointConnectionRequest, **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] + ) -> Optional[_models.PrivateEndpointConnection]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] _json = self._serialize.body(private_endpoint_connection_request, 'PrivateEndpointConnectionRequest') @@ -203,17 +233,24 @@ async def _create_or_update_initial( service_name=service_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -226,7 +263,7 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async @@ -235,9 +272,9 @@ async def begin_create_or_update( resource_group_name: str, service_name: str, private_endpoint_connection_name: str, - private_endpoint_connection_request: "_models.PrivateEndpointConnectionRequest", + private_endpoint_connection_request: _models.PrivateEndpointConnectionRequest, **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Creates a new Private Endpoint Connection or updates an existing one. :param resource_group_name: The name of the resource group. @@ -248,7 +285,7 @@ async def begin_create_or_update( :type private_endpoint_connection_name: str :param private_endpoint_connection_request: :type private_endpoint_connection_request: - ~api_management_client.models.PrivateEndpointConnectionRequest + ~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 @@ -260,39 +297,51 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.PrivateEndpointConnection] + ~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"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection_request=private_endpoint_connection_request, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **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() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -301,23 +350,27 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -325,12 +378,19 @@ async def _delete_initial( service_name=service_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -340,11 +400,11 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async - async def begin_delete( + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -371,19 +431,26 @@ async def begin_delete( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -393,8 +460,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -403,10 +476,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def list_private_link_resources( @@ -414,8 +486,8 @@ async def list_private_link_resources( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": - """Description for Gets the private link resources. + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -423,26 +495,38 @@ async def list_private_link_resources( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkResourceListResult, or the result of cls(response) - :rtype: ~api_management_client.models.PrivateLinkResourceListResult + :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_list_private_link_resources_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, service_name=service_name, + api_version=api_version, template_url=self.list_private_link_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -457,7 +541,7 @@ async def list_private_link_resources( return deserialized - list_private_link_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources'} # type: ignore + list_private_link_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources"} # type: ignore @distributed_trace_async @@ -467,8 +551,8 @@ async def get_private_link_resource( service_name: str, private_link_sub_resource_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResource": - """Description for Gets the private link resources. + ) -> _models.PrivateLinkResource: + """Gets the private link resources. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -478,14 +562,19 @@ async def get_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: ~api_management_client.models.PrivateLinkResource + :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResource] request = build_get_private_link_resource_request( @@ -493,12 +582,19 @@ async def get_private_link_resource( subscription_id=self._config.subscription_id, service_name=service_name, private_link_sub_resource_name=private_link_sub_resource_name, + api_version=api_version, template_url=self.get_private_link_resource.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -513,5 +609,5 @@ async def get_private_link_resource( return deserialized - get_private_link_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources/{privateLinkSubResourceName}'} # type: ignore + get_private_link_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources/{privateLinkSubResourceName}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_operations.py index ca2e8352d498..35fa6266cbf2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._product_api_operations import build_check_entity_exists_request, build_create_or_update_request, build_delete_request, build_list_by_product_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ProductApiOperations: - """ProductApiOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`product_api` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_product( @@ -56,7 +55,7 @@ def list_by_product( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ApiCollection"]: + ) -> AsyncIterable[_models.ApiCollection]: """Lists a collection of the APIs associated with a product. :param resource_group_name: The name of the resource group. @@ -73,22 +72,27 @@ def list_by_product( |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| serviceUrl | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
. + startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ApiCollection] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -97,13 +101,16 @@ def prepare_request(next_link=None): service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_product.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -112,13 +119,16 @@ def prepare_request(next_link=None): service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -132,7 +142,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,7 +160,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis'} # type: ignore + list_by_product.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis"} # type: ignore @distributed_trace_async async def check_entity_exists( @@ -174,11 +188,16 @@ async def check_entity_exists( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_check_entity_exists_request( @@ -187,12 +206,19 @@ async def check_entity_exists( product_id=product_id, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.check_entity_exists.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -204,7 +230,7 @@ async def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} # type: ignore + check_entity_exists.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}"} # type: ignore @distributed_trace_async @@ -215,7 +241,7 @@ async def create_or_update( product_id: str, api_id: str, **kwargs: Any - ) -> "_models.ApiContract": + ) -> _models.ApiContract: """Adds an API to the specified product. :param resource_group_name: The name of the resource group. @@ -230,14 +256,19 @@ async def create_or_update( :type api_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiContract + :rtype: ~azure.mgmt.apimanagement.models.ApiContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiContract] request = build_create_or_update_request( @@ -246,12 +277,19 @@ async def create_or_update( product_id=product_id, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -270,11 +308,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -299,11 +337,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -312,12 +355,19 @@ async def delete( product_id=product_id, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -328,5 +378,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_operations.py index 94c57e93cf86..b41d15b7aa86 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._product_group_operations import build_check_entity_exists_request, build_create_or_update_request, build_delete_request, build_list_by_product_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ProductGroupOperations: - """ProductGroupOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`product_group` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_product( @@ -56,7 +55,7 @@ def list_by_product( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.GroupCollection"]: + ) -> AsyncIterable[_models.GroupCollection]: """Lists the collection of developer groups associated with the specified product. :param resource_group_name: The name of the resource group. @@ -69,22 +68,28 @@ def list_by_product( :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt | |
| displayName | filter | eq, ne | |
| - description | filter | eq, ne | |
. + description | filter | eq, ne | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GroupCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.GroupCollection] + :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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GroupCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -93,13 +98,16 @@ def prepare_request(next_link=None): service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_product.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -108,13 +116,16 @@ def prepare_request(next_link=None): service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +139,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -142,7 +157,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups'} # type: ignore + list_by_product.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups"} # type: ignore @distributed_trace_async async def check_entity_exists( @@ -170,11 +185,16 @@ async def check_entity_exists( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_check_entity_exists_request( @@ -183,12 +203,19 @@ async def check_entity_exists( product_id=product_id, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.check_entity_exists.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -200,7 +227,7 @@ async def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} # type: ignore + check_entity_exists.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}"} # type: ignore @distributed_trace_async @@ -211,7 +238,7 @@ async def create_or_update( product_id: str, group_id: str, **kwargs: Any - ) -> "_models.GroupContract": + ) -> _models.GroupContract: """Adds the association between the specified developer group with the specified product. :param resource_group_name: The name of the resource group. @@ -226,14 +253,19 @@ async def create_or_update( :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GroupContract, or the result of cls(response) - :rtype: ~api_management_client.models.GroupContract + :rtype: ~azure.mgmt.apimanagement.models.GroupContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GroupContract] request = build_create_or_update_request( @@ -242,12 +274,19 @@ async def create_or_update( product_id=product_id, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -266,11 +305,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -295,11 +334,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -308,12 +352,19 @@ async def delete( product_id=product_id, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -324,5 +375,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_operations.py index b674f7c7d02e..367a32f93269 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._product_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_list_by_tags_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ProductOperations: - """ProductOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`product` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -57,7 +56,7 @@ def list_by_service( expand_groups: Optional[bool] = None, tags: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ProductCollection"]: + ) -> AsyncIterable[_models.ProductCollection]: """Lists a collection of products in the specified service instance. :param resource_group_name: The name of the resource group. @@ -70,28 +69,34 @@ def list_by_service( displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| terms | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| state | filter | eq | |
| groups | expand | | |
. + endswith |
| state | filter | eq | |
| groups | expand | | |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :param expand_groups: When set to true, the response contains an array of groups that have visibility to the product. The default is false. :type expand_groups: bool - :param tags: Products which are part of a specific tag. + :param tags: Products which are part of a specific tag. Default value is None. :type tags: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProductCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ProductCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProductCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -99,15 +104,18 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, expand_groups=expand_groups, tags=tags, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -115,15 +123,18 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, expand_groups=expand_groups, tags=tags, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -137,7 +148,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -151,7 +166,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -175,11 +190,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -187,12 +207,19 @@ async def get_entity_tag( service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -208,7 +235,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # type: ignore @distributed_trace_async @@ -218,7 +245,7 @@ async def get( service_name: str, product_id: str, **kwargs: Any - ) -> "_models.ProductContract": + ) -> _models.ProductContract: """Gets the details of the product specified by its identifier. :param resource_group_name: The name of the resource group. @@ -230,14 +257,19 @@ async def get( :type product_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ProductContract, or the result of cls(response) - :rtype: ~api_management_client.models.ProductContract + :rtype: ~azure.mgmt.apimanagement.models.ProductContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProductContract] request = build_get_request( @@ -245,12 +277,19 @@ async def get( service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -268,7 +307,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # type: ignore @distributed_trace_async @@ -277,10 +316,10 @@ async def create_or_update( resource_group_name: str, service_name: str, product_id: str, - parameters: "_models.ProductContract", + parameters: _models.ProductContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ProductContract": + ) -> _models.ProductContract: """Creates or Updates a product. :param resource_group_name: The name of the resource group. @@ -291,22 +330,26 @@ async def create_or_update( instance. :type product_id: str :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.ProductContract + :type parameters: ~azure.mgmt.apimanagement.models.ProductContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ProductContract, or the result of cls(response) - :rtype: ~api_management_client.models.ProductContract + :rtype: ~azure.mgmt.apimanagement.models.ProductContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProductContract] _json = self._serialize.body(parameters, 'ProductContract') @@ -315,15 +358,22 @@ async def create_or_update( service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -347,7 +397,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # type: ignore @distributed_trace_async @@ -357,9 +407,9 @@ async def update( service_name: str, product_id: str, if_match: str, - parameters: "_models.ProductUpdateParameters", + parameters: _models.ProductUpdateParameters, **kwargs: Any - ) -> "_models.ProductContract": + ) -> _models.ProductContract: """Update existing product details. :param resource_group_name: The name of the resource group. @@ -373,19 +423,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.ProductUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.ProductUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: ProductContract, or the result of cls(response) - :rtype: ~api_management_client.models.ProductContract + :rtype: ~azure.mgmt.apimanagement.models.ProductContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProductContract] _json = self._serialize.body(parameters, 'ProductUpdateParameters') @@ -394,15 +448,22 @@ async def update( service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -420,11 +481,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -446,17 +507,23 @@ async def delete( response of the GET request or it should be * for unconditional update. :type if_match: str :param delete_subscriptions: Delete existing subscriptions associated with the product or not. + Default value is None. :type delete_subscriptions: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -464,14 +531,21 @@ async def delete( service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, delete_subscriptions=delete_subscriptions, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -482,7 +556,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # type: ignore @distributed_trace @@ -495,7 +569,7 @@ def list_by_tags( skip: Optional[int] = None, include_not_tagged_products: Optional[bool] = None, **kwargs: Any - ) -> AsyncIterable["_models.TagResourceCollection"]: + ) -> AsyncIterable[_models.TagResourceCollection]: """Lists a collection of products associated with tags. :param resource_group_name: The name of the resource group. @@ -509,25 +583,31 @@ def list_by_tags( |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| terms | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| state | filter | eq | substringof, contains, startswith, endswith |
. + Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param include_not_tagged_products: Include not tagged Products. + :param include_not_tagged_products: Include not tagged Products. Default value is None. :type include_not_tagged_products: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagResourceCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TagResourceCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagResourceCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -535,14 +615,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, include_not_tagged_products=include_not_tagged_products, template_url=self.list_by_tags.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -550,14 +633,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, include_not_tagged_products=include_not_tagged_products, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -571,7 +657,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -585,4 +675,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/productsByTags'} # type: ignore + list_by_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/productsByTags"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_policy_operations.py index 1929f57392e9..a51ba234dd7e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_policy_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,44 +6,42 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._product_policy_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_by_product_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ProductPolicyOperations: - """ProductPolicyOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`product_policy` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_product( @@ -51,7 +50,7 @@ async def list_by_product( service_name: str, product_id: str, **kwargs: Any - ) -> "_models.PolicyCollection": + ) -> _models.PolicyCollection: """Get the policy configuration at the Product level. :param resource_group_name: The name of the resource group. @@ -63,14 +62,19 @@ async def list_by_product( :type product_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyCollection + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyCollection] request = build_list_by_product_request( @@ -78,12 +82,19 @@ async def list_by_product( service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_product.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -98,7 +109,7 @@ async def list_by_product( return deserialized - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies'} # type: ignore + list_by_product.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies"} # type: ignore @distributed_trace_async @@ -120,17 +131,22 @@ async def get_entity_tag( instance. :type product_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: bool, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -139,12 +155,19 @@ async def get_entity_tag( product_id=product_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -160,7 +183,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}"} # type: ignore @distributed_trace_async @@ -172,7 +195,7 @@ async def get( policy_id: Union[str, "_models.PolicyIdName"], format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Get the policy configuration at the Product level. :param resource_group_name: The name of the resource group. @@ -183,19 +206,24 @@ async def get( instance. :type product_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param format: Policy Export Format. - :type format: str or ~api_management_client.models.PolicyExportFormat + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. Default value is "xml". + :type format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyContract] request = build_get_request( @@ -204,13 +232,20 @@ async def get( product_id=product_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, format=format, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -228,7 +263,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}"} # type: ignore @distributed_trace_async @@ -238,10 +273,10 @@ async def create_or_update( service_name: str, product_id: str, policy_id: Union[str, "_models.PolicyIdName"], - parameters: "_models.PolicyContract", + parameters: _models.PolicyContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Creates or updates policy configuration for the Product. :param resource_group_name: The name of the resource group. @@ -252,24 +287,28 @@ async def create_or_update( instance. :type product_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :param parameters: The policy contents to apply. - :type parameters: ~api_management_client.models.PolicyContract + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyContract] _json = self._serialize.body(parameters, 'PolicyContract') @@ -279,15 +318,22 @@ async def create_or_update( product_id=product_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -311,11 +357,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -334,7 +380,7 @@ async def delete( instance. :type product_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str @@ -343,11 +389,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -356,13 +407,20 @@ async def delete( product_id=product_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -373,5 +431,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_subscriptions_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_subscriptions_operations.py index a258bb53ce26..fa288dfb90aa 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_subscriptions_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_subscriptions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,36 +14,35 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._product_subscriptions_operations import build_list_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ProductSubscriptionsOperations: - """ProductSubscriptionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`product_subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -56,7 +54,7 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionCollection"]: + ) -> AsyncIterable[_models.SubscriptionCollection]: """Lists the collection of subscriptions to the specified product. :param resource_group_name: The name of the resource group. @@ -76,24 +74,29 @@ def list( endswith |
| userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| productId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| state | filter | eq | |
| user | expand | | - |
. + |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SubscriptionCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.SubscriptionCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -102,13 +105,16 @@ def prepare_request(next_link=None): service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -117,13 +123,16 @@ def prepare_request(next_link=None): service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -137,7 +146,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -151,4 +164,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/subscriptions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/subscriptions"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_counter_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_counter_keys_operations.py index 330c216fef8b..cd7fc10f0f77 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_counter_keys_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_counter_keys_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,44 +6,42 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._quota_by_counter_keys_operations import build_list_by_service_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QuotaByCounterKeysOperations: - """QuotaByCounterKeysOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`quota_by_counter_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_service( @@ -51,7 +50,7 @@ async def list_by_service( service_name: str, quota_counter_key: str, **kwargs: Any - ) -> "_models.QuotaCounterCollection": + ) -> _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. @@ -66,14 +65,19 @@ async def list_by_service( :type quota_counter_key: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QuotaCounterCollection, or the result of cls(response) - :rtype: ~api_management_client.models.QuotaCounterCollection + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaCounterCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QuotaCounterCollection] request = build_list_by_service_request( @@ -81,12 +85,19 @@ async def list_by_service( service_name=service_name, quota_counter_key=quota_counter_key, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,7 +112,7 @@ async def list_by_service( return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}"} # type: ignore @distributed_trace_async @@ -110,9 +121,9 @@ async def update( resource_group_name: str, service_name: str, quota_counter_key: str, - parameters: "_models.QuotaCounterValueUpdateContract", + parameters: _models.QuotaCounterValueUpdateContract, **kwargs: Any - ) -> "_models.QuotaCounterCollection": + ) -> _models.QuotaCounterCollection: """Updates all the quota counter values specified with the existing quota counter key to a value in the specified service instance. This should be used for reset of the quota counter values. @@ -126,19 +137,23 @@ async def update( as counter-key="@("b"+"a")" then it will be accessible by "ba" key. :type quota_counter_key: str :param parameters: The value of the quota counter to be applied to all quota counter periods. - :type parameters: ~api_management_client.models.QuotaCounterValueUpdateContract + :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract :keyword callable cls: A custom type or function that will be passed the direct response :return: QuotaCounterCollection, or the result of cls(response) - :rtype: ~api_management_client.models.QuotaCounterCollection + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaCounterCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.QuotaCounterCollection] _json = self._serialize.body(parameters, 'QuotaCounterValueUpdateContract') @@ -147,14 +162,21 @@ async def update( service_name=service_name, quota_counter_key=quota_counter_key, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,5 +191,5 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_period_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_period_keys_operations.py index d3833e77f2a7..72af5c51a8d1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_period_keys_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_period_keys_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,44 +6,42 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._quota_by_period_keys_operations import build_get_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QuotaByPeriodKeysOperations: - """QuotaByPeriodKeysOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`quota_by_period_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -52,7 +51,7 @@ async def get( quota_counter_key: str, quota_period_key: str, **kwargs: Any - ) -> "_models.QuotaCounterContract": + ) -> _models.QuotaCounterContract: """Gets the value of the quota counter associated with the counter-key in the policy for the specific period in service instance. @@ -69,14 +68,19 @@ async def get( :type quota_period_key: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QuotaCounterContract, or the result of cls(response) - :rtype: ~api_management_client.models.QuotaCounterContract + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaCounterContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QuotaCounterContract] request = build_get_request( @@ -85,12 +89,19 @@ async def get( quota_counter_key=quota_counter_key, quota_period_key=quota_period_key, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,7 +116,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}"} # type: ignore @distributed_trace_async @@ -115,9 +126,9 @@ async def update( service_name: str, quota_counter_key: str, quota_period_key: str, - parameters: "_models.QuotaCounterValueUpdateContract", + parameters: _models.QuotaCounterValueUpdateContract, **kwargs: Any - ) -> "_models.QuotaCounterContract": + ) -> _models.QuotaCounterContract: """Updates an existing quota counter value in the specified service instance. :param resource_group_name: The name of the resource group. @@ -132,19 +143,23 @@ async def update( :param quota_period_key: Quota period key identifier. :type quota_period_key: str :param parameters: The value of the Quota counter to be applied on the specified period. - :type parameters: ~api_management_client.models.QuotaCounterValueUpdateContract + :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract :keyword callable cls: A custom type or function that will be passed the direct response :return: QuotaCounterContract, or the result of cls(response) - :rtype: ~api_management_client.models.QuotaCounterContract + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaCounterContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.QuotaCounterContract] _json = self._serialize.body(parameters, 'QuotaCounterValueUpdateContract') @@ -154,14 +169,21 @@ async def update( quota_counter_key=quota_counter_key, quota_period_key=quota_period_key, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -176,5 +198,5 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_region_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_region_operations.py index 48c3f86af353..44507c257c97 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_region_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_region_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,36 +14,35 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._region_operations import build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RegionOperations: - """RegionOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`region` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -52,7 +50,7 @@ def list_by_service( resource_group_name: str, service_name: str, **kwargs: Any - ) -> AsyncIterable["_models.RegionListResult"]: + ) -> AsyncIterable[_models.RegionListResult]: """Lists all azure regions in which the service exists. :param resource_group_name: The name of the resource group. @@ -61,14 +59,20 @@ 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[~api_management_client.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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RegionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,10 +80,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,10 +94,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -104,7 +114,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,4 +132,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/regions'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/regions"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_reports_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_reports_operations.py index 385b86887fe2..8e9a5c76e149 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_reports_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_reports_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,36 +15,35 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._reports_operations import build_list_by_api_request, build_list_by_geo_request, build_list_by_operation_request, build_list_by_product_request, build_list_by_request_request, build_list_by_subscription_request, build_list_by_time_request, build_list_by_user_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ReportsOperations: - """ReportsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`reports` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_api( @@ -57,7 +55,7 @@ def list_by_api( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ReportCollection"]: + ) -> AsyncIterable[_models.ReportCollection]: """Lists report records by API. :param resource_group_name: The name of the resource group. @@ -66,22 +64,28 @@ def list_by_api( :type service_name: str :param filter: The filter to apply on the operation. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ReportCollection] + :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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -89,14 +93,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=self.list_by_api.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -104,14 +111,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -125,7 +135,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,7 +153,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi'} # type: ignore + list_by_api.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi"} # type: ignore @distributed_trace def list_by_user( @@ -151,7 +165,7 @@ def list_by_user( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ReportCollection"]: + ) -> AsyncIterable[_models.ReportCollection]: """Lists report records by User. :param resource_group_name: The name of the resource group. @@ -172,22 +186,28 @@ def list_by_user(
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ReportCollection] + :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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -195,14 +215,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=self.list_by_user.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -210,14 +233,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -231,7 +257,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -245,7 +275,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_user.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser'} # type: ignore + list_by_user.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser"} # type: ignore @distributed_trace def list_by_operation( @@ -257,7 +287,7 @@ def list_by_operation( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ReportCollection"]: + ) -> AsyncIterable[_models.ReportCollection]: """Lists report records by API Operations. :param resource_group_name: The name of the resource group. @@ -278,22 +308,28 @@ def list_by_operation(
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ReportCollection] + :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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -301,14 +337,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=self.list_by_operation.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -316,14 +355,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -337,7 +379,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -351,7 +397,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation'} # type: ignore + list_by_operation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation"} # type: ignore @distributed_trace def list_by_product( @@ -363,7 +409,7 @@ def list_by_product( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ReportCollection"]: + ) -> AsyncIterable[_models.ReportCollection]: """Lists report records by Product. :param resource_group_name: The name of the resource group. @@ -383,22 +429,28 @@ def list_by_product(
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ReportCollection] + :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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -406,14 +458,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=self.list_by_product.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -421,14 +476,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -442,7 +500,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -456,7 +518,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct'} # type: ignore + list_by_product.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct"} # type: ignore @distributed_trace def list_by_geo( @@ -467,7 +529,7 @@ def list_by_geo( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ReportCollection"]: + ) -> AsyncIterable[_models.ReportCollection]: """Lists report records by geography. :param resource_group_name: The name of the resource group. @@ -488,20 +550,26 @@ def list_by_geo( serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ReportCollection] + :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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -509,13 +577,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_geo.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -523,13 +594,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -543,7 +617,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -557,7 +635,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_geo.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo'} # type: ignore + list_by_geo.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo"} # type: ignore @distributed_trace def list_by_subscription( @@ -569,7 +647,7 @@ def list_by_subscription( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ReportCollection"]: + ) -> AsyncIterable[_models.ReportCollection]: """Lists report records by subscription. :param resource_group_name: The name of the resource group. @@ -589,22 +667,28 @@ def list_by_subscription(
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ReportCollection] + :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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -612,14 +696,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -627,14 +714,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -648,7 +738,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -662,7 +756,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription"} # type: ignore @distributed_trace def list_by_time( @@ -675,7 +769,7 @@ def list_by_time( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ReportCollection"]: + ) -> AsyncIterable[_models.ReportCollection]: """Lists report records by Time. :param resource_group_name: The name of the resource group. @@ -700,22 +794,28 @@ def list_by_time( code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :type interval: ~datetime.timedelta - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.ReportCollection] + :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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -723,15 +823,18 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, interval=interval, top=top, skip=skip, orderby=orderby, template_url=self.list_by_time.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -739,15 +842,18 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, interval=interval, top=top, skip=skip, orderby=orderby, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -761,7 +867,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -775,7 +885,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_time.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime'} # type: ignore + list_by_time.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime"} # type: ignore @distributed_trace def list_by_request( @@ -786,7 +896,7 @@ def list_by_request( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.RequestReportCollection"]: + ) -> AsyncIterable[_models.RequestReportCollection]: """Lists report records by Request. :param resource_group_name: The name of the resource group. @@ -799,22 +909,27 @@ def list_by_request( |
| productId | filter | eq | |
| userId | filter | eq | |
| apiRegion | filter | eq | |
| subscriptionId | filter | eq | |
. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RequestReportCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.RequestReportCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.RequestReportCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RequestReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RequestReportCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -822,13 +937,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_request.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -836,13 +954,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -856,7 +977,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -870,4 +995,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_request.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest'} # type: ignore + list_by_request.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_in_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_in_settings_operations.py index 7a1093beb971..bd25a5499c0a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_in_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_in_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,44 +6,42 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._sign_in_settings_operations import build_create_or_update_request, build_get_entity_tag_request, build_get_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SignInSettingsOperations: - """SignInSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`sign_in_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get_entity_tag( @@ -62,23 +61,35 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -94,7 +105,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin"} # type: ignore @distributed_trace_async @@ -103,7 +114,7 @@ async def get( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.PortalSigninSettings": + ) -> _models.PortalSigninSettings: """Get Sign In Settings for the Portal. :param resource_group_name: The name of the resource group. @@ -112,26 +123,38 @@ async def get( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PortalSigninSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSigninSettings + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSigninSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalSigninSettings] request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -149,16 +172,16 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin"} # type: ignore @distributed_trace_async - async def update( + async def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, if_match: str, - parameters: "_models.PortalSigninSettings", + parameters: _models.PortalSigninSettings, **kwargs: Any ) -> None: """Update Sign-In settings. @@ -171,19 +194,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update Sign-In settings. - :type parameters: ~api_management_client.models.PortalSigninSettings + :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(parameters, 'PortalSigninSettings') @@ -191,15 +218,22 @@ async def update( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -210,7 +244,7 @@ async def update( if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin"} # type: ignore @distributed_trace_async @@ -218,10 +252,10 @@ async def create_or_update( self, resource_group_name: str, service_name: str, - parameters: "_models.PortalSigninSettings", + parameters: _models.PortalSigninSettings, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PortalSigninSettings": + ) -> _models.PortalSigninSettings: """Create or Update Sign-In settings. :param resource_group_name: The name of the resource group. @@ -229,22 +263,26 @@ async def create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.PortalSigninSettings + :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PortalSigninSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSigninSettings + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSigninSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalSigninSettings] _json = self._serialize.body(parameters, 'PortalSigninSettings') @@ -252,15 +290,22 @@ async def create_or_update( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -275,5 +320,5 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_up_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_up_settings_operations.py index 37588cdb4399..386ead5781d4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_up_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_up_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,44 +6,42 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._sign_up_settings_operations import build_create_or_update_request, build_get_entity_tag_request, build_get_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SignUpSettingsOperations: - """SignUpSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`sign_up_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get_entity_tag( @@ -62,23 +61,35 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -94,7 +105,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup"} # type: ignore @distributed_trace_async @@ -103,7 +114,7 @@ async def get( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.PortalSignupSettings": + ) -> _models.PortalSignupSettings: """Get Sign Up Settings for the Portal. :param resource_group_name: The name of the resource group. @@ -112,26 +123,38 @@ async def get( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PortalSignupSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSignupSettings + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSignupSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalSignupSettings] request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -149,16 +172,16 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup"} # type: ignore @distributed_trace_async - async def update( + async def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, if_match: str, - parameters: "_models.PortalSignupSettings", + parameters: _models.PortalSignupSettings, **kwargs: Any ) -> None: """Update Sign-Up settings. @@ -171,19 +194,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update Sign-Up settings. - :type parameters: ~api_management_client.models.PortalSignupSettings + :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(parameters, 'PortalSignupSettings') @@ -191,15 +218,22 @@ async def update( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -210,7 +244,7 @@ async def update( if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup"} # type: ignore @distributed_trace_async @@ -218,10 +252,10 @@ async def create_or_update( self, resource_group_name: str, service_name: str, - parameters: "_models.PortalSignupSettings", + parameters: _models.PortalSignupSettings, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PortalSignupSettings": + ) -> _models.PortalSignupSettings: """Create or Update Sign-Up settings. :param resource_group_name: The name of the resource group. @@ -229,22 +263,26 @@ async def create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.PortalSignupSettings + :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PortalSignupSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSignupSettings + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSignupSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalSignupSettings] _json = self._serialize.body(parameters, 'PortalSignupSettings') @@ -252,15 +290,22 @@ async def create_or_update( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -275,5 +320,5 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_subscription_operations.py index 247563b8f3ab..7fb5777c9976 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_subscription_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_subscription_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._subscription_operations import build_create_or_update_request, build_delete_request, build_get_entity_tag_request, build_get_request, build_list_request, build_list_secrets_request, build_regenerate_primary_key_request, build_regenerate_secondary_key_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SubscriptionOperations: - """SubscriptionOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`subscription` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -55,7 +54,7 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionCollection"]: + ) -> AsyncIterable[_models.SubscriptionCollection]: """Lists all subscriptions of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -72,24 +71,29 @@ def list( endswith |
| userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| productId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| state | filter | eq | |
| user | expand | | - |
. + |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SubscriptionCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.SubscriptionCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -97,13 +101,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -111,13 +118,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -131,7 +141,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -145,7 +159,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -170,11 +184,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -182,12 +201,19 @@ async def get_entity_tag( service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -203,7 +229,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # type: ignore @distributed_trace_async @@ -213,7 +239,7 @@ async def get( service_name: str, sid: str, **kwargs: Any - ) -> "_models.SubscriptionContract": + ) -> _models.SubscriptionContract: """Gets the specified Subscription entity. :param resource_group_name: The name of the resource group. @@ -225,14 +251,19 @@ async def get( :type sid: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionContract + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionContract] request = build_get_request( @@ -240,12 +271,19 @@ async def get( service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -263,7 +301,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # type: ignore @distributed_trace_async @@ -272,12 +310,12 @@ async def create_or_update( resource_group_name: str, service_name: str, sid: str, - parameters: "_models.SubscriptionCreateParameters", + parameters: _models.SubscriptionCreateParameters, notify: Optional[bool] = None, if_match: Optional[str] = None, app_type: Optional[Union[str, "_models.AppType"]] = None, **kwargs: Any - ) -> "_models.SubscriptionContract": + ) -> _models.SubscriptionContract: """Creates or updates the subscription of specified user to the specified product. :param resource_group_name: The name of the resource group. @@ -288,31 +326,35 @@ async def create_or_update( user and a product in API Management. :type sid: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.SubscriptionCreateParameters + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionCreateParameters :param notify: Notify change in Subscription State. * If false, do not send any email notification for change of state of subscription - * If true, send email notification of change of state of subscription. + * If true, send email notification of change of state of subscription. Default value is None. :type notify: bool :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :param app_type: Determines the type of application which send the create user request. Default is legacy publisher portal. - :type app_type: str or ~api_management_client.models.AppType + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionContract + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionContract] _json = self._serialize.body(parameters, 'SubscriptionCreateParameters') @@ -321,17 +363,24 @@ async def create_or_update( service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, notify=notify, if_match=if_match, app_type=app_type, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -355,7 +404,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # type: ignore @distributed_trace_async @@ -365,11 +414,11 @@ async def update( service_name: str, sid: str, if_match: str, - parameters: "_models.SubscriptionUpdateParameters", + parameters: _models.SubscriptionUpdateParameters, notify: Optional[bool] = None, app_type: Optional[Union[str, "_models.AppType"]] = None, **kwargs: Any - ) -> "_models.SubscriptionContract": + ) -> _models.SubscriptionContract: """Updates the details of a subscription specified by its identifier. :param resource_group_name: The name of the resource group. @@ -383,28 +432,32 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.SubscriptionUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionUpdateParameters :param notify: Notify change in Subscription State. * If false, do not send any email notification for change of state of subscription - * If true, send email notification of change of state of subscription. + * If true, send email notification of change of state of subscription. Default value is None. :type notify: bool :param app_type: Determines the type of application which send the create user request. Default is legacy publisher portal. - :type app_type: str or ~api_management_client.models.AppType + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionContract + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionContract] _json = self._serialize.body(parameters, 'SubscriptionUpdateParameters') @@ -413,17 +466,24 @@ async def update( service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, notify=notify, app_type=app_type, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -441,11 +501,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -470,11 +530,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -482,13 +547,20 @@ async def delete( service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -499,11 +571,11 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # type: ignore @distributed_trace_async - async def regenerate_primary_key( + async def regenerate_primary_key( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -524,11 +596,16 @@ async def regenerate_primary_key( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_regenerate_primary_key_request( @@ -536,12 +613,19 @@ async def regenerate_primary_key( service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.regenerate_primary_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -552,11 +636,11 @@ async def regenerate_primary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_primary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regeneratePrimaryKey'} # type: ignore + regenerate_primary_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regeneratePrimaryKey"} # type: ignore @distributed_trace_async - async def regenerate_secondary_key( + async def regenerate_secondary_key( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -577,11 +661,16 @@ async def regenerate_secondary_key( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_regenerate_secondary_key_request( @@ -589,12 +678,19 @@ async def regenerate_secondary_key( service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.regenerate_secondary_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -605,7 +701,7 @@ async def regenerate_secondary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regenerateSecondaryKey'} # type: ignore + regenerate_secondary_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regenerateSecondaryKey"} # type: ignore @distributed_trace_async @@ -615,7 +711,7 @@ async def list_secrets( service_name: str, sid: str, **kwargs: Any - ) -> "_models.SubscriptionKeysContract": + ) -> _models.SubscriptionKeysContract: """Gets the specified Subscription keys. :param resource_group_name: The name of the resource group. @@ -627,14 +723,19 @@ async def list_secrets( :type sid: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionKeysContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionKeysContract + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionKeysContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionKeysContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionKeysContract] request = build_list_secrets_request( @@ -642,12 +743,19 @@ async def list_secrets( service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_secrets.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -665,5 +773,5 @@ async def list_secrets( return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/listSecrets'} # type: ignore + list_secrets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operations.py index 5c4d59e3d95b..87f66eee3d35 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._tag_operations import build_assign_to_api_request, build_assign_to_operation_request, build_assign_to_product_request, build_create_or_update_request, build_delete_request, build_detach_from_api_request, build_detach_from_operation_request, build_detach_from_product_request, build_get_by_api_request, build_get_by_operation_request, build_get_by_product_request, build_get_entity_state_by_api_request, build_get_entity_state_by_operation_request, build_get_entity_state_by_product_request, build_get_entity_state_request, build_get_request, build_list_by_api_request, build_list_by_operation_request, build_list_by_product_request, build_list_by_service_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TagOperations: - """TagOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TagOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tag` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_operation( @@ -57,7 +56,7 @@ def list_by_operation( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.TagCollection"]: + ) -> AsyncIterable[_models.TagCollection]: """Lists all Tags associated with the Operation. :param resource_group_name: The name of the resource group. @@ -73,22 +72,28 @@ def list_by_operation( :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TagCollection] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -98,13 +103,16 @@ def prepare_request(next_link=None): api_id=api_id, operation_id=operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_operation.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -114,13 +122,16 @@ def prepare_request(next_link=None): api_id=api_id, operation_id=operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -134,7 +145,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -148,7 +163,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags'} # type: ignore + list_by_operation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags"} # type: ignore @distributed_trace_async async def get_entity_state_by_operation( @@ -179,11 +194,16 @@ async def get_entity_state_by_operation( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_state_by_operation_request( @@ -193,12 +213,19 @@ async def get_entity_state_by_operation( operation_id=operation_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_state_by_operation.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,7 +241,7 @@ async def get_entity_state_by_operation( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_state_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore + get_entity_state_by_operation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}"} # type: ignore @distributed_trace_async @@ -226,7 +253,7 @@ async def get_by_operation( operation_id: str, tag_id: str, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Get tag associated with the Operation. :param resource_group_name: The name of the resource group. @@ -243,14 +270,19 @@ async def get_by_operation( :type tag_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract + :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagContract] request = build_get_by_operation_request( @@ -260,12 +292,19 @@ async def get_by_operation( operation_id=operation_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_by_operation.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -283,7 +322,7 @@ async def get_by_operation( return deserialized - get_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore + get_by_operation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}"} # type: ignore @distributed_trace_async @@ -295,7 +334,7 @@ async def assign_to_operation( operation_id: str, tag_id: str, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Assign tag to the Operation. :param resource_group_name: The name of the resource group. @@ -312,14 +351,19 @@ async def assign_to_operation( :type tag_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract + :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagContract] request = build_assign_to_operation_request( @@ -329,12 +373,19 @@ async def assign_to_operation( operation_id=operation_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.assign_to_operation.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -353,11 +404,11 @@ async def assign_to_operation( return deserialized - assign_to_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore + assign_to_operation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}"} # type: ignore @distributed_trace_async - async def detach_from_operation( + async def detach_from_operation( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -385,11 +436,16 @@ async def detach_from_operation( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_detach_from_operation_request( @@ -399,12 +455,19 @@ async def detach_from_operation( operation_id=operation_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.detach_from_operation.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -415,7 +478,7 @@ async def detach_from_operation( if cls: return cls(pipeline_response, None, {}) - detach_from_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore + detach_from_operation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}"} # type: ignore @distributed_trace @@ -428,7 +491,7 @@ def list_by_api( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.TagCollection"]: + ) -> AsyncIterable[_models.TagCollection]: """Lists all Tags associated with the API. :param resource_group_name: The name of the resource group. @@ -441,22 +504,28 @@ def list_by_api( :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TagCollection] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -465,13 +534,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_api.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -480,13 +552,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -500,7 +575,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -514,7 +593,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags'} # type: ignore + list_by_api.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags"} # type: ignore @distributed_trace_async async def get_entity_state_by_api( @@ -541,11 +620,16 @@ async def get_entity_state_by_api( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_state_by_api_request( @@ -554,12 +638,19 @@ async def get_entity_state_by_api( api_id=api_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_state_by_api.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -575,7 +666,7 @@ async def get_entity_state_by_api( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_state_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore + get_entity_state_by_api.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}"} # type: ignore @distributed_trace_async @@ -586,7 +677,7 @@ async def get_by_api( api_id: str, tag_id: str, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Get tag associated with the API. :param resource_group_name: The name of the resource group. @@ -600,14 +691,19 @@ async def get_by_api( :type tag_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract + :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagContract] request = build_get_by_api_request( @@ -616,12 +712,19 @@ async def get_by_api( api_id=api_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_by_api.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -639,7 +742,7 @@ async def get_by_api( return deserialized - get_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore + get_by_api.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}"} # type: ignore @distributed_trace_async @@ -650,7 +753,7 @@ async def assign_to_api( api_id: str, tag_id: str, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Assign tag to the Api. :param resource_group_name: The name of the resource group. @@ -664,14 +767,19 @@ async def assign_to_api( :type tag_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract + :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagContract] request = build_assign_to_api_request( @@ -680,12 +788,19 @@ async def assign_to_api( api_id=api_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.assign_to_api.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -709,11 +824,11 @@ async def assign_to_api( return deserialized - assign_to_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore + assign_to_api.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}"} # type: ignore @distributed_trace_async - async def detach_from_api( + async def detach_from_api( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -737,11 +852,16 @@ async def detach_from_api( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_detach_from_api_request( @@ -750,12 +870,19 @@ async def detach_from_api( api_id=api_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.detach_from_api.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -766,7 +893,7 @@ async def detach_from_api( if cls: return cls(pipeline_response, None, {}) - detach_from_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore + detach_from_api.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}"} # type: ignore @distributed_trace @@ -779,7 +906,7 @@ def list_by_product( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.TagCollection"]: + ) -> AsyncIterable[_models.TagCollection]: """Lists all Tags associated with the Product. :param resource_group_name: The name of the resource group. @@ -792,22 +919,28 @@ def list_by_product( :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TagCollection] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -816,13 +949,16 @@ def prepare_request(next_link=None): service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_product.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -831,13 +967,16 @@ def prepare_request(next_link=None): service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -851,7 +990,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -865,7 +1008,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags'} # type: ignore + list_by_product.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags"} # type: ignore @distributed_trace_async async def get_entity_state_by_product( @@ -892,11 +1035,16 @@ async def get_entity_state_by_product( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_state_by_product_request( @@ -905,12 +1053,19 @@ async def get_entity_state_by_product( product_id=product_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_state_by_product.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -926,7 +1081,7 @@ async def get_entity_state_by_product( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_state_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore + get_entity_state_by_product.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}"} # type: ignore @distributed_trace_async @@ -937,7 +1092,7 @@ async def get_by_product( product_id: str, tag_id: str, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Get tag associated with the Product. :param resource_group_name: The name of the resource group. @@ -951,14 +1106,19 @@ async def get_by_product( :type tag_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract + :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagContract] request = build_get_by_product_request( @@ -967,12 +1127,19 @@ async def get_by_product( product_id=product_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_by_product.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -990,7 +1157,7 @@ async def get_by_product( return deserialized - get_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore + get_by_product.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}"} # type: ignore @distributed_trace_async @@ -1001,7 +1168,7 @@ async def assign_to_product( product_id: str, tag_id: str, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Assign tag to the Product. :param resource_group_name: The name of the resource group. @@ -1015,14 +1182,19 @@ async def assign_to_product( :type tag_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract + :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagContract] request = build_assign_to_product_request( @@ -1031,12 +1203,19 @@ async def assign_to_product( product_id=product_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.assign_to_product.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1055,11 +1234,11 @@ async def assign_to_product( return deserialized - assign_to_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore + assign_to_product.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}"} # type: ignore @distributed_trace_async - async def detach_from_product( + async def detach_from_product( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -1083,11 +1262,16 @@ async def detach_from_product( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_detach_from_product_request( @@ -1096,12 +1280,19 @@ async def detach_from_product( product_id=product_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.detach_from_product.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1112,7 +1303,7 @@ async def detach_from_product( if cls: return cls(pipeline_response, None, {}) - detach_from_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore + detach_from_product.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}"} # type: ignore @distributed_trace @@ -1125,7 +1316,7 @@ def list_by_service( skip: Optional[int] = None, scope: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.TagCollection"]: + ) -> AsyncIterable[_models.TagCollection]: """Lists a collection of tags defined within a service instance. :param resource_group_name: The name of the resource group. @@ -1136,24 +1327,29 @@ def list_by_service( functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
. + |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param scope: Scope like 'apis', 'products' or 'apis/{apiId}. + :param scope: Scope like 'apis', 'products' or 'apis/{apiId}. Default value is None. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TagCollection] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1161,14 +1357,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, scope=scope, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1176,14 +1375,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, scope=scope, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1197,7 +1399,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1211,7 +1417,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags"} # type: ignore @distributed_trace_async async def get_entity_state( @@ -1234,11 +1440,16 @@ async def get_entity_state( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_state_request( @@ -1246,12 +1457,19 @@ async def get_entity_state( service_name=service_name, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_state.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1267,7 +1485,7 @@ async def get_entity_state( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_state.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore + get_entity_state.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # type: ignore @distributed_trace_async @@ -1277,7 +1495,7 @@ async def get( service_name: str, tag_id: str, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Gets the details of the tag specified by its identifier. :param resource_group_name: The name of the resource group. @@ -1288,14 +1506,19 @@ async def get( :type tag_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract + :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagContract] request = build_get_request( @@ -1303,12 +1526,19 @@ async def get( service_name=service_name, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1326,7 +1556,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # type: ignore @distributed_trace_async @@ -1335,10 +1565,10 @@ async def create_or_update( resource_group_name: str, service_name: str, tag_id: str, - parameters: "_models.TagCreateUpdateParameters", + parameters: _models.TagCreateUpdateParameters, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Creates a tag. :param resource_group_name: The name of the resource group. @@ -1348,22 +1578,26 @@ async def create_or_update( :param tag_id: Tag identifier. Must be unique in the current API Management service instance. :type tag_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.TagCreateUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract + :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagContract] _json = self._serialize.body(parameters, 'TagCreateUpdateParameters') @@ -1372,15 +1606,22 @@ async def create_or_update( service_name=service_name, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1404,7 +1645,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # type: ignore @distributed_trace_async @@ -1414,9 +1655,9 @@ async def update( service_name: str, tag_id: str, if_match: str, - parameters: "_models.TagCreateUpdateParameters", + parameters: _models.TagCreateUpdateParameters, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Updates the details of the tag specified by its identifier. :param resource_group_name: The name of the resource group. @@ -1429,19 +1670,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.TagCreateUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract + :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagContract] _json = self._serialize.body(parameters, 'TagCreateUpdateParameters') @@ -1450,15 +1695,22 @@ async def update( service_name=service_name, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1476,11 +1728,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -1504,11 +1756,16 @@ async def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -1516,13 +1773,20 @@ async def delete( service_name=service_name, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1533,5 +1797,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_resource_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_resource_operations.py index 1d905815a541..708706ff8ede 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_resource_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,36 +14,35 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._tag_resource_operations import build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TagResourceOperations: - """TagResourceOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tag_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -55,7 +53,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.TagResourceCollection"]: + ) -> AsyncIterable[_models.TagResourceCollection]: """Lists a collection of resources associated with tags. :param resource_group_name: The name of the resource group. @@ -76,24 +74,29 @@ def list_by_service( contains, startswith, endswith |
| urlTemplate | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| terms | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| state | filter | eq | |
| isCurrent - | filter | eq | |
. + | filter | eq | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagResourceCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TagResourceCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagResourceCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -101,13 +104,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -115,13 +121,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -135,7 +144,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -149,4 +162,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tagResources'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tagResources"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_git_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_git_operations.py index 802ddf006e4e..d0564d07afbd 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_git_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_git_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,47 +6,45 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._tenant_access_git_operations import build_regenerate_primary_key_request, build_regenerate_secondary_key_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TenantAccessGitOperations: - """TenantAccessGitOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tenant_access_git` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async - async def regenerate_primary_key( + async def regenerate_primary_key( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -59,17 +58,22 @@ async def regenerate_primary_key( :param service_name: The name of the API Management service. :type service_name: str :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_regenerate_primary_key_request( @@ -77,12 +81,19 @@ async def regenerate_primary_key( service_name=service_name, subscription_id=self._config.subscription_id, access_name=access_name, + api_version=api_version, template_url=self.regenerate_primary_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -93,11 +104,11 @@ async def regenerate_primary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_primary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regeneratePrimaryKey'} # type: ignore + regenerate_primary_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regeneratePrimaryKey"} # type: ignore @distributed_trace_async - async def regenerate_secondary_key( + async def regenerate_secondary_key( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -111,17 +122,22 @@ async def regenerate_secondary_key( :param service_name: The name of the API Management service. :type service_name: str :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_regenerate_secondary_key_request( @@ -129,12 +145,19 @@ async def regenerate_secondary_key( service_name=service_name, subscription_id=self._config.subscription_id, access_name=access_name, + api_version=api_version, template_url=self.regenerate_secondary_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -145,5 +168,5 @@ async def regenerate_secondary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regenerateSecondaryKey'} # type: ignore + regenerate_secondary_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regenerateSecondaryKey"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_operations.py index 310e0cda7e5b..6e88160da111 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._tenant_access_operations import build_create_request, build_get_entity_tag_request, build_get_request, build_list_by_service_request, build_list_secrets_request, build_regenerate_primary_key_request, build_regenerate_secondary_key_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TenantAccessOperations: - """TenantAccessOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tenant_access` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -53,27 +52,32 @@ def list_by_service( service_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessInformationCollection"]: + ) -> AsyncIterable[_models.AccessInformationCollection]: """Returns list of access infos - for Git and Management endpoints. :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: Not used. + :param filter: Not used. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessInformationCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.AccessInformationCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AccessInformationCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessInformationCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,11 +85,14 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -93,11 +100,14 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -111,7 +121,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -125,7 +139,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -142,17 +156,22 @@ async def get_entity_tag( :param service_name: The name of the API Management service. :type service_name: str :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: bool, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -160,12 +179,19 @@ async def get_entity_tag( service_name=service_name, subscription_id=self._config.subscription_id, access_name=access_name, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,7 +207,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}"} # type: ignore @distributed_trace_async @@ -191,7 +217,7 @@ async def get( service_name: str, access_name: Union[str, "_models.AccessIdName"], **kwargs: Any - ) -> "_models.AccessInformationContract": + ) -> _models.AccessInformationContract: """Get tenant access information details without secrets. :param resource_group_name: The name of the resource group. @@ -199,17 +225,22 @@ async def get( :param service_name: The name of the API Management service. :type service_name: str :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessInformationContract, or the result of cls(response) - :rtype: ~api_management_client.models.AccessInformationContract + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessInformationContract] request = build_get_request( @@ -217,12 +248,19 @@ async def get( service_name=service_name, subscription_id=self._config.subscription_id, access_name=access_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -240,7 +278,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}"} # type: ignore @distributed_trace_async @@ -250,9 +288,9 @@ async def create( service_name: str, access_name: Union[str, "_models.AccessIdName"], if_match: str, - parameters: "_models.AccessInformationCreateParameters", + parameters: _models.AccessInformationCreateParameters, **kwargs: Any - ) -> "_models.AccessInformationContract": + ) -> _models.AccessInformationContract: """Update tenant access information details. :param resource_group_name: The name of the resource group. @@ -260,24 +298,28 @@ async def create( :param service_name: The name of the API Management service. :type service_name: str :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Parameters supplied to retrieve the Tenant Access Information. - :type parameters: ~api_management_client.models.AccessInformationCreateParameters + :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessInformationContract, or the result of cls(response) - :rtype: ~api_management_client.models.AccessInformationContract + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessInformationContract] _json = self._serialize.body(parameters, 'AccessInformationCreateParameters') @@ -286,15 +328,22 @@ async def create( service_name=service_name, access_name=access_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -312,7 +361,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}"} # type: ignore @distributed_trace_async @@ -322,9 +371,9 @@ async def update( service_name: str, access_name: Union[str, "_models.AccessIdName"], if_match: str, - parameters: "_models.AccessInformationUpdateParameters", + parameters: _models.AccessInformationUpdateParameters, **kwargs: Any - ) -> "_models.AccessInformationContract": + ) -> _models.AccessInformationContract: """Update tenant access information details. :param resource_group_name: The name of the resource group. @@ -332,24 +381,28 @@ async def update( :param service_name: The name of the API Management service. :type service_name: str :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Parameters supplied to retrieve the Tenant Access Information. - :type parameters: ~api_management_client.models.AccessInformationUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessInformationContract, or the result of cls(response) - :rtype: ~api_management_client.models.AccessInformationContract + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessInformationContract] _json = self._serialize.body(parameters, 'AccessInformationUpdateParameters') @@ -358,15 +411,22 @@ async def update( service_name=service_name, access_name=access_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -384,11 +444,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}"} # type: ignore @distributed_trace_async - async def regenerate_primary_key( + async def regenerate_primary_key( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -402,17 +462,22 @@ async def regenerate_primary_key( :param service_name: The name of the API Management service. :type service_name: str :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_regenerate_primary_key_request( @@ -420,12 +485,19 @@ async def regenerate_primary_key( service_name=service_name, subscription_id=self._config.subscription_id, access_name=access_name, + api_version=api_version, template_url=self.regenerate_primary_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -436,11 +508,11 @@ async def regenerate_primary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_primary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regeneratePrimaryKey'} # type: ignore + regenerate_primary_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regeneratePrimaryKey"} # type: ignore @distributed_trace_async - async def regenerate_secondary_key( + async def regenerate_secondary_key( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -454,17 +526,22 @@ async def regenerate_secondary_key( :param service_name: The name of the API Management service. :type service_name: str :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_regenerate_secondary_key_request( @@ -472,12 +549,19 @@ async def regenerate_secondary_key( service_name=service_name, subscription_id=self._config.subscription_id, access_name=access_name, + api_version=api_version, template_url=self.regenerate_secondary_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -488,7 +572,7 @@ async def regenerate_secondary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regenerateSecondaryKey'} # type: ignore + regenerate_secondary_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regenerateSecondaryKey"} # type: ignore @distributed_trace_async @@ -498,7 +582,7 @@ async def list_secrets( service_name: str, access_name: Union[str, "_models.AccessIdName"], **kwargs: Any - ) -> "_models.AccessInformationSecretsContract": + ) -> _models.AccessInformationSecretsContract: """Get tenant access information details. :param resource_group_name: The name of the resource group. @@ -506,17 +590,22 @@ async def list_secrets( :param service_name: The name of the API Management service. :type service_name: str :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessInformationSecretsContract, or the result of cls(response) - :rtype: ~api_management_client.models.AccessInformationSecretsContract + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationSecretsContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationSecretsContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessInformationSecretsContract] request = build_list_secrets_request( @@ -524,12 +613,19 @@ async def list_secrets( service_name=service_name, subscription_id=self._config.subscription_id, access_name=access_name, + api_version=api_version, template_url=self.list_secrets.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -547,5 +643,5 @@ async def list_secrets( return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/listSecrets'} # type: ignore + list_secrets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_configuration_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_configuration_operations.py index 6407d2097f13..e07f9d02817a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_configuration_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_configuration_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -15,52 +14,56 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request from ...operations._tenant_configuration_operations import build_deploy_request_initial, build_get_sync_state_request, build_save_request_initial, build_validate_request_initial +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TenantConfigurationOperations: - """TenantConfigurationOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tenant_configuration` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _deploy_initial( self, resource_group_name: str, service_name: str, configuration_name: Union[str, "_models.ConfigurationIdName"], - parameters: "_models.DeployConfigurationParameters", + parameters: _models.DeployConfigurationParameters, **kwargs: Any - ) -> Optional["_models.OperationResultContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResultContract"]] + ) -> Optional[_models.OperationResultContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationResultContract]] _json = self._serialize.body(parameters, 'DeployConfigurationParameters') @@ -69,14 +72,21 @@ async def _deploy_initial( service_name=service_name, subscription_id=self._config.subscription_id, configuration_name=configuration_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._deploy_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -92,7 +102,7 @@ async def _deploy_initial( return deserialized - _deploy_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy'} # type: ignore + _deploy_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy"} # type: ignore @distributed_trace_async @@ -101,9 +111,9 @@ async def begin_deploy( resource_group_name: str, service_name: str, configuration_name: Union[str, "_models.ConfigurationIdName"], - parameters: "_models.DeployConfigurationParameters", + parameters: _models.DeployConfigurationParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationResultContract"]: + ) -> AsyncLROPoller[_models.OperationResultContract]: """This operation applies changes from the specified Git branch to the configuration database. This is a long running operation and could take several minutes to complete. @@ -112,9 +122,9 @@ async def begin_deploy( :param service_name: The name of the API Management service. :type service_name: str :param configuration_name: The identifier of the Git Configuration Operation. - :type configuration_name: str or ~api_management_client.models.ConfigurationIdName + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName :param parameters: Deploy Configuration parameters. - :type parameters: ~api_management_client.models.DeployConfigurationParameters + :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 @@ -126,39 +136,51 @@ async def begin_deploy( :return: An instance of AsyncLROPoller that returns either OperationResultContract or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.OperationResultContract] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResultContract"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationResultContract] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._deploy_initial( + raw_result = await self._deploy_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, configuration_name=configuration_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -167,26 +189,29 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_deploy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy'} # type: ignore + begin_deploy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy"} # type: ignore async def _save_initial( self, resource_group_name: str, service_name: str, configuration_name: Union[str, "_models.ConfigurationIdName"], - parameters: "_models.SaveConfigurationParameter", + parameters: _models.SaveConfigurationParameter, **kwargs: Any - ) -> Optional["_models.OperationResultContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResultContract"]] + ) -> Optional[_models.OperationResultContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationResultContract]] _json = self._serialize.body(parameters, 'SaveConfigurationParameter') @@ -195,14 +220,21 @@ async def _save_initial( service_name=service_name, subscription_id=self._config.subscription_id, configuration_name=configuration_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._save_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -218,7 +250,7 @@ async def _save_initial( return deserialized - _save_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save'} # type: ignore + _save_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save"} # type: ignore @distributed_trace_async @@ -227,9 +259,9 @@ async def begin_save( resource_group_name: str, service_name: str, configuration_name: Union[str, "_models.ConfigurationIdName"], - parameters: "_models.SaveConfigurationParameter", + parameters: _models.SaveConfigurationParameter, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationResultContract"]: + ) -> AsyncLROPoller[_models.OperationResultContract]: """This operation creates a commit with the current configuration snapshot to the specified branch in the repository. This is a long running operation and could take several minutes to complete. @@ -238,9 +270,9 @@ async def begin_save( :param service_name: The name of the API Management service. :type service_name: str :param configuration_name: The identifier of the Git Configuration Operation. - :type configuration_name: str or ~api_management_client.models.ConfigurationIdName + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName :param parameters: Save Configuration parameters. - :type parameters: ~api_management_client.models.SaveConfigurationParameter + :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 @@ -252,39 +284,51 @@ async def begin_save( :return: An instance of AsyncLROPoller that returns either OperationResultContract or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.OperationResultContract] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResultContract"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationResultContract] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._save_initial( + raw_result = await self._save_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, configuration_name=configuration_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -293,26 +337,29 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_save.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save'} # type: ignore + begin_save.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save"} # type: ignore async def _validate_initial( self, resource_group_name: str, service_name: str, configuration_name: Union[str, "_models.ConfigurationIdName"], - parameters: "_models.DeployConfigurationParameters", + parameters: _models.DeployConfigurationParameters, **kwargs: Any - ) -> Optional["_models.OperationResultContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResultContract"]] + ) -> Optional[_models.OperationResultContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationResultContract]] _json = self._serialize.body(parameters, 'DeployConfigurationParameters') @@ -321,14 +368,21 @@ async def _validate_initial( service_name=service_name, subscription_id=self._config.subscription_id, configuration_name=configuration_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._validate_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -344,7 +398,7 @@ async def _validate_initial( return deserialized - _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate'} # type: ignore + _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate"} # type: ignore @distributed_trace_async @@ -353,9 +407,9 @@ async def begin_validate( resource_group_name: str, service_name: str, configuration_name: Union[str, "_models.ConfigurationIdName"], - parameters: "_models.DeployConfigurationParameters", + parameters: _models.DeployConfigurationParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationResultContract"]: + ) -> AsyncLROPoller[_models.OperationResultContract]: """This operation validates the changes in the specified Git branch. This is a long running operation and could take several minutes to complete. @@ -364,9 +418,9 @@ async def begin_validate( :param service_name: The name of the API Management service. :type service_name: str :param configuration_name: The identifier of the Git Configuration Operation. - :type configuration_name: str or ~api_management_client.models.ConfigurationIdName + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName :param parameters: Validate Configuration parameters. - :type parameters: ~api_management_client.models.DeployConfigurationParameters + :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 @@ -378,39 +432,51 @@ async def begin_validate( :return: An instance of AsyncLROPoller that returns either OperationResultContract or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~api_management_client.models.OperationResultContract] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResultContract"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationResultContract] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._validate_initial( + raw_result = await self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, configuration_name=configuration_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -419,10 +485,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate'} # type: ignore + begin_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate"} # type: ignore @distributed_trace_async async def get_sync_state( @@ -431,7 +496,7 @@ async def get_sync_state( service_name: str, configuration_name: Union[str, "_models.ConfigurationIdName"], **kwargs: Any - ) -> "_models.TenantConfigurationSyncStateContract": + ) -> _models.TenantConfigurationSyncStateContract: """Gets the status of the most recent synchronization between the configuration database and the Git repository. @@ -440,17 +505,22 @@ async def get_sync_state( :param service_name: The name of the API Management service. :type service_name: str :param configuration_name: The identifier of the Git Configuration Operation. - :type configuration_name: str or ~api_management_client.models.ConfigurationIdName + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: TenantConfigurationSyncStateContract, or the result of cls(response) - :rtype: ~api_management_client.models.TenantConfigurationSyncStateContract + :rtype: ~azure.mgmt.apimanagement.models.TenantConfigurationSyncStateContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantConfigurationSyncStateContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TenantConfigurationSyncStateContract] request = build_get_sync_state_request( @@ -458,12 +528,19 @@ async def get_sync_state( service_name=service_name, subscription_id=self._config.subscription_id, configuration_name=configuration_name, + api_version=api_version, template_url=self.get_sync_state.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -478,5 +555,5 @@ async def get_sync_state( return deserialized - get_sync_state.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/syncState'} # type: ignore + get_sync_state.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/syncState"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_settings_operations.py index 942d49f3f2d5..a85f0f0fec64 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._tenant_settings_operations import build_get_request, build_list_by_service_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TenantSettingsOperations: - """TenantSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tenant_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -53,27 +52,32 @@ def list_by_service( service_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.TenantSettingsCollection"]: + ) -> AsyncIterable[_models.TenantSettingsCollection]: """Public settings. :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: Not used. + :param filter: Not used. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TenantSettingsCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.TenantSettingsCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TenantSettingsCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantSettingsCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TenantSettingsCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,11 +85,14 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -93,11 +100,14 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -111,7 +121,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -125,7 +139,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings"} # type: ignore @distributed_trace_async async def get( @@ -134,7 +148,7 @@ async def get( service_name: str, settings_type: Union[str, "_models.SettingsTypeName"], **kwargs: Any - ) -> "_models.TenantSettingsContract": + ) -> _models.TenantSettingsContract: """Get tenant settings. :param resource_group_name: The name of the resource group. @@ -142,17 +156,22 @@ async def get( :param service_name: The name of the API Management service. :type service_name: str :param settings_type: The identifier of the settings. - :type settings_type: str or ~api_management_client.models.SettingsTypeName + :type settings_type: str or ~azure.mgmt.apimanagement.models.SettingsTypeName :keyword callable cls: A custom type or function that will be passed the direct response :return: TenantSettingsContract, or the result of cls(response) - :rtype: ~api_management_client.models.TenantSettingsContract + :rtype: ~azure.mgmt.apimanagement.models.TenantSettingsContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantSettingsContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TenantSettingsContract] request = build_get_request( @@ -160,12 +179,19 @@ async def get( service_name=service_name, subscription_id=self._config.subscription_id, settings_type=settings_type, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -183,5 +209,5 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings/{settingsType}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings/{settingsType}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_confirmation_password_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_confirmation_password_operations.py index 77393221ff69..b18f5b858182 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_confirmation_password_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_confirmation_password_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,47 +6,45 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._user_confirmation_password_operations import build_send_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UserConfirmationPasswordOperations: - """UserConfirmationPasswordOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`user_confirmation_password` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async - async def send( + async def send( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -63,17 +62,22 @@ async def send( :type user_id: str :param app_type: Determines the type of application which send the create user request. Default is legacy publisher portal. - :type app_type: str or ~api_management_client.models.AppType + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_send_request( @@ -81,13 +85,20 @@ async def send( service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, app_type=app_type, template_url=self.send.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -98,5 +109,5 @@ async def send( if cls: return cls(pipeline_response, None, {}) - send.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/confirmations/password/send'} # type: ignore + send.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/confirmations/password/send"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_group_operations.py index 999bdde3666b..9fa536934240 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_group_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_group_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,36 +14,35 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._user_group_operations import build_list_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UserGroupOperations: - """UserGroupOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`user_group` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -56,7 +54,7 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.GroupCollection"]: + ) -> AsyncIterable[_models.GroupCollection]: """Lists all user groups. :param resource_group_name: The name of the resource group. @@ -71,22 +69,28 @@ def list( filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
. + endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GroupCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.GroupCollection] + :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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GroupCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -95,13 +99,16 @@ def prepare_request(next_link=None): service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -110,13 +117,16 @@ def prepare_request(next_link=None): service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -130,7 +140,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -144,4 +158,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/groups'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/groups"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_identities_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_identities_operations.py index 8f42f24c06d6..e18d8b21e716 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_identities_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_identities_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,36 +14,35 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._user_identities_operations import build_list_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UserIdentitiesOperations: - """UserIdentitiesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`user_identities` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -53,7 +51,7 @@ def list( service_name: str, user_id: str, **kwargs: Any - ) -> AsyncIterable["_models.UserIdentityCollection"]: + ) -> AsyncIterable[_models.UserIdentityCollection]: """List of all user identities. :param resource_group_name: The name of the resource group. @@ -66,14 +64,19 @@ def list( :return: An iterator like instance of either UserIdentityCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.UserIdentityCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.UserIdentityCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserIdentityCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserIdentityCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -82,10 +85,13 @@ def prepare_request(next_link=None): service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -94,10 +100,13 @@ def prepare_request(next_link=None): service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -111,7 +120,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -125,4 +138,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/identities'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/identities"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_operations.py index f51f16963a15..404d894e9193 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._user_operations import build_create_or_update_request, build_delete_request, build_generate_sso_url_request, build_get_entity_tag_request, build_get_request, build_get_shared_access_token_request, build_list_by_service_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UserOperations: - """UserOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`user` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -56,7 +55,7 @@ def list_by_service( skip: Optional[int] = None, expand_groups: Optional[bool] = None, **kwargs: Any - ) -> AsyncIterable["_models.UserCollection"]: + ) -> AsyncIterable[_models.UserCollection]: """Lists a collection of registered users in the specified service instance. :param resource_group_name: The name of the resource group. @@ -71,24 +70,30 @@ def list_by_service( |
| email | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| state | filter | eq | |
| registrationDate | filter | ge, le, eq, ne, gt, lt | |
| note | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
| groups | expand | | |
. + |
| groups | expand | | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param expand_groups: Detailed Group in response. + :param expand_groups: Detailed Group in response. Default value is None. :type expand_groups: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either UserCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.UserCollection] + :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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -96,14 +101,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, expand_groups=expand_groups, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -111,14 +119,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, expand_groups=expand_groups, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -132,7 +143,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -146,7 +161,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users"} # type: ignore @distributed_trace_async async def get_entity_tag( @@ -169,11 +184,16 @@ async def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -181,12 +201,19 @@ async def get_entity_tag( service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -202,7 +229,7 @@ async def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # type: ignore @distributed_trace_async @@ -212,7 +239,7 @@ async def get( service_name: str, user_id: str, **kwargs: Any - ) -> "_models.UserContract": + ) -> _models.UserContract: """Gets the details of the user specified by its identifier. :param resource_group_name: The name of the resource group. @@ -223,14 +250,19 @@ async def get( :type user_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: UserContract, or the result of cls(response) - :rtype: ~api_management_client.models.UserContract + :rtype: ~azure.mgmt.apimanagement.models.UserContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserContract] request = build_get_request( @@ -238,12 +270,19 @@ async def get( service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -261,7 +300,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # type: ignore @distributed_trace_async @@ -270,11 +309,11 @@ async def create_or_update( resource_group_name: str, service_name: str, user_id: str, - parameters: "_models.UserCreateParameters", + parameters: _models.UserCreateParameters, notify: Optional[bool] = None, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.UserContract": + ) -> _models.UserContract: """Creates or Updates a user. :param resource_group_name: The name of the resource group. @@ -284,24 +323,28 @@ async def create_or_update( :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.UserCreateParameters - :param notify: Send an Email notification to the User. + :type parameters: ~azure.mgmt.apimanagement.models.UserCreateParameters + :param notify: Send an Email notification to the User. Default value is None. :type notify: bool :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: UserContract, or the result of cls(response) - :rtype: ~api_management_client.models.UserContract + :rtype: ~azure.mgmt.apimanagement.models.UserContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserContract] _json = self._serialize.body(parameters, 'UserCreateParameters') @@ -310,16 +353,23 @@ async def create_or_update( service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, notify=notify, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -343,7 +393,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # type: ignore @distributed_trace_async @@ -353,9 +403,9 @@ async def update( service_name: str, user_id: str, if_match: str, - parameters: "_models.UserUpdateParameters", + parameters: _models.UserUpdateParameters, **kwargs: Any - ) -> "_models.UserContract": + ) -> _models.UserContract: """Updates the details of the user specified by its identifier. :param resource_group_name: The name of the resource group. @@ -368,19 +418,23 @@ async def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.UserUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.UserUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: UserContract, or the result of cls(response) - :rtype: ~api_management_client.models.UserContract + :rtype: ~azure.mgmt.apimanagement.models.UserContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserContract] _json = self._serialize.body(parameters, 'UserUpdateParameters') @@ -389,15 +443,22 @@ async def update( service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -415,11 +476,11 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -441,23 +502,29 @@ async def delete( :param if_match: ETag of 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 - :param delete_subscriptions: Whether to delete user's subscription or not. + :param delete_subscriptions: Whether to delete user's subscription or not. Default value is + None. :type delete_subscriptions: bool - :param notify: Send an Account Closed Email notification to the User. + :param notify: Send an Account Closed Email notification to the User. Default value is None. :type notify: bool :param app_type: Determines the type of application which send the create user request. Default is legacy publisher portal. - :type app_type: str or ~api_management_client.models.AppType + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -465,16 +532,23 @@ async def delete( service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, delete_subscriptions=delete_subscriptions, notify=notify, app_type=app_type, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -485,7 +559,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # type: ignore @distributed_trace_async @@ -495,7 +569,7 @@ async def generate_sso_url( service_name: str, user_id: str, **kwargs: Any - ) -> "_models.GenerateSsoUrlResult": + ) -> _models.GenerateSsoUrlResult: """Retrieves a redirection URL containing an authentication token for signing a given user into the developer portal. @@ -507,14 +581,19 @@ async def generate_sso_url( :type user_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GenerateSsoUrlResult, or the result of cls(response) - :rtype: ~api_management_client.models.GenerateSsoUrlResult + :rtype: ~azure.mgmt.apimanagement.models.GenerateSsoUrlResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateSsoUrlResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GenerateSsoUrlResult] request = build_generate_sso_url_request( @@ -522,12 +601,19 @@ async def generate_sso_url( service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.generate_sso_url.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -542,7 +628,7 @@ async def generate_sso_url( return deserialized - generate_sso_url.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/generateSsoUrl'} # type: ignore + generate_sso_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/generateSsoUrl"} # type: ignore @distributed_trace_async @@ -551,9 +637,9 @@ async def get_shared_access_token( resource_group_name: str, service_name: str, user_id: str, - parameters: "_models.UserTokenParameters", + parameters: _models.UserTokenParameters, **kwargs: Any - ) -> "_models.UserTokenResult": + ) -> _models.UserTokenResult: """Gets the Shared Access Authorization Token for the User. :param resource_group_name: The name of the resource group. @@ -563,19 +649,23 @@ async def get_shared_access_token( :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str :param parameters: Create Authorization Token parameters. - :type parameters: ~api_management_client.models.UserTokenParameters + :type parameters: ~azure.mgmt.apimanagement.models.UserTokenParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: UserTokenResult, or the result of cls(response) - :rtype: ~api_management_client.models.UserTokenResult + :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserTokenResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserTokenResult] _json = self._serialize.body(parameters, 'UserTokenParameters') @@ -584,14 +674,21 @@ async def get_shared_access_token( service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.get_shared_access_token.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -606,5 +703,5 @@ async def get_shared_access_token( return deserialized - get_shared_access_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/token'} # type: ignore + get_shared_access_token.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/token"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_subscription_operations.py index 91eadd808aed..aec6b13b9d0e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_subscription_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_subscription_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._user_subscription_operations import build_get_request, build_list_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UserSubscriptionOperations: - """UserSubscriptionOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`user_subscription` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -56,7 +55,7 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionCollection"]: + ) -> AsyncIterable[_models.SubscriptionCollection]: """Lists the collection of subscriptions of the specified user. :param resource_group_name: The name of the resource group. @@ -74,24 +73,29 @@ def list( startswith, endswith |
|scope | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
|userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
|productId | filter | ge, le, eq, ne, gt, lt | substringof, - contains, startswith, endswith |
. + contains, startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SubscriptionCollection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~api_management_client.models.SubscriptionCollection] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -100,13 +104,16 @@ def prepare_request(next_link=None): service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -115,13 +122,16 @@ def prepare_request(next_link=None): service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -135,7 +145,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -149,7 +163,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions"} # type: ignore @distributed_trace_async async def get( @@ -159,7 +173,7 @@ async def get( user_id: str, sid: str, **kwargs: Any - ) -> "_models.SubscriptionContract": + ) -> _models.SubscriptionContract: """Gets the specified Subscription entity associated with a particular user. :param resource_group_name: The name of the resource group. @@ -173,14 +187,19 @@ async def get( :type sid: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionContract + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionContract] request = build_get_request( @@ -189,12 +208,19 @@ async def get( user_id=user_id, sid=sid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -212,5 +238,5 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions/{sid}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions/{sid}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/__init__.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/__init__.py index d83a3cafb3e3..ec973422909b 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 @@ -66,6 +66,17 @@ from ._models_py3 import ArmIdWrapper from ._models_py3 import AssociationContract from ._models_py3 import AuthenticationSettingsContract +from ._models_py3 import AuthorizationAccessPolicyCollection +from ._models_py3 import AuthorizationAccessPolicyContract +from ._models_py3 import AuthorizationCollection +from ._models_py3 import AuthorizationContract +from ._models_py3 import AuthorizationError +from ._models_py3 import AuthorizationLoginRequestContract +from ._models_py3 import AuthorizationLoginResponseContract +from ._models_py3 import AuthorizationProviderCollection +from ._models_py3 import AuthorizationProviderContract +from ._models_py3 import AuthorizationProviderOAuth2GrantTypes +from ._models_py3 import AuthorizationProviderOAuth2Settings from ._models_py3 import AuthorizationServerCollection from ._models_py3 import AuthorizationServerContract from ._models_py3 import AuthorizationServerContractBaseProperties @@ -209,6 +220,16 @@ from ._models_py3 import PolicyContract from ._models_py3 import PolicyDescriptionCollection from ._models_py3 import PolicyDescriptionContract +from ._models_py3 import PolicyFragmentCollection +from ._models_py3 import PolicyFragmentContract +from ._models_py3 import PortalConfigCollection +from ._models_py3 import PortalConfigContract +from ._models_py3 import PortalConfigCorsProperties +from ._models_py3 import PortalConfigCspProperties +from ._models_py3 import PortalConfigDelegationProperties +from ._models_py3 import PortalConfigPropertiesSignin +from ._models_py3 import PortalConfigPropertiesSignup +from ._models_py3 import PortalConfigTermsOfServiceProperties from ._models_py3 import PortalDelegationSettings from ._models_py3 import PortalRevisionCollection from ._models_py3 import PortalRevisionContract @@ -253,6 +274,8 @@ from ._models_py3 import RequestReportCollection from ._models_py3 import RequestReportRecordContract from ._models_py3 import Resource +from ._models_py3 import ResourceCollection +from ._models_py3 import ResourceCollectionValueItem from ._models_py3 import ResourceLocationDataContract from ._models_py3 import ResourceSku from ._models_py3 import ResourceSkuCapacity @@ -317,6 +340,7 @@ AppType, AsyncOperationStatus, AuthorizationMethod, + AuthorizationType, BackendProtocol, BearerTokenSendingMethod, BearerTokenSendingMethods, @@ -346,14 +370,17 @@ Method, NameAvailabilityReason, NotificationName, + OAuth2GrantType, OperationNameFormat, Origin, PlatformVersion, PolicyContentFormat, PolicyExportFormat, + PolicyFragmentContentFormat, PolicyIdName, PolicyScopeContract, PortalRevisionStatus, + PortalSettingsCspMode, PreferredIPVersion, PrivateEndpointConnectionProvisioningState, PrivateEndpointServiceConnectionStatus, @@ -375,7 +402,9 @@ VersioningScheme, VirtualNetworkType, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'AccessInformationCollection', 'AccessInformationContract', @@ -437,6 +466,17 @@ 'ArmIdWrapper', 'AssociationContract', 'AuthenticationSettingsContract', + 'AuthorizationAccessPolicyCollection', + 'AuthorizationAccessPolicyContract', + 'AuthorizationCollection', + 'AuthorizationContract', + 'AuthorizationError', + 'AuthorizationLoginRequestContract', + 'AuthorizationLoginResponseContract', + 'AuthorizationProviderCollection', + 'AuthorizationProviderContract', + 'AuthorizationProviderOAuth2GrantTypes', + 'AuthorizationProviderOAuth2Settings', 'AuthorizationServerCollection', 'AuthorizationServerContract', 'AuthorizationServerContractBaseProperties', @@ -580,6 +620,16 @@ 'PolicyContract', 'PolicyDescriptionCollection', 'PolicyDescriptionContract', + 'PolicyFragmentCollection', + 'PolicyFragmentContract', + 'PortalConfigCollection', + 'PortalConfigContract', + 'PortalConfigCorsProperties', + 'PortalConfigCspProperties', + 'PortalConfigDelegationProperties', + 'PortalConfigPropertiesSignin', + 'PortalConfigPropertiesSignup', + 'PortalConfigTermsOfServiceProperties', 'PortalDelegationSettings', 'PortalRevisionCollection', 'PortalRevisionContract', @@ -624,6 +674,8 @@ 'RequestReportCollection', 'RequestReportRecordContract', 'Resource', + 'ResourceCollection', + 'ResourceCollectionValueItem', 'ResourceLocationDataContract', 'ResourceSku', 'ResourceSkuCapacity', @@ -685,6 +737,7 @@ 'AppType', 'AsyncOperationStatus', 'AuthorizationMethod', + 'AuthorizationType', 'BackendProtocol', 'BearerTokenSendingMethod', 'BearerTokenSendingMethods', @@ -714,14 +767,17 @@ 'Method', 'NameAvailabilityReason', 'NotificationName', + 'OAuth2GrantType', 'OperationNameFormat', 'Origin', 'PlatformVersion', 'PolicyContentFormat', 'PolicyExportFormat', + 'PolicyFragmentContentFormat', 'PolicyIdName', 'PolicyScopeContract', 'PortalRevisionStatus', + 'PortalSettingsCspMode', 'PreferredIPVersion', 'PrivateEndpointConnectionProvisioningState', 'PrivateEndpointServiceConnectionStatus', @@ -743,3 +799,5 @@ 'VersioningScheme', 'VirtualNetworkType', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 b194dd14e518..9556dca080c9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_api_management_client_enums.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_api_management_client_enums.py @@ -7,16 +7,15 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessIdName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessIdName(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCESS = "access" GIT_ACCESS = "gitAccess" -class AccessType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of access to be used for the storage account. """ @@ -27,14 +26,14 @@ class AccessType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Use user assigned managed identity. USER_ASSIGNED_MANAGED_IDENTITY = "UserAssignedManagedIdentity" -class AlwaysLog(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AlwaysLog(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies for what type of messages sampling settings should not apply. """ #: Always log all erroneous request regardless of sampling settings. ALL_ERRORS = "allErrors" -class ApiManagementSkuCapacityScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ApiManagementSkuCapacityScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ @@ -42,21 +41,21 @@ class ApiManagementSkuCapacityScaleType(with_metaclass(CaseInsensitiveEnumMeta, MANUAL = "Manual" NONE = "None" -class ApiManagementSkuRestrictionsReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ApiManagementSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for restriction. """ QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class ApiManagementSkuRestrictionsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ApiManagementSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of restrictions. """ LOCATION = "Location" ZONE = "Zone" -class ApimIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ApimIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the service. @@ -67,7 +66,7 @@ class ApimIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class ApiType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ApiType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of API. """ @@ -76,7 +75,7 @@ class ApiType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WEBSOCKET = "websocket" GRAPHQL = "graphql" -class ApiVersionSetContractDetailsVersioningScheme(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ApiVersionSetContractDetailsVersioningScheme(str, Enum, metaclass=CaseInsensitiveEnumMeta): """An value that determines where the API Version identifier will be located in a HTTP request. """ @@ -84,14 +83,14 @@ class ApiVersionSetContractDetailsVersioningScheme(with_metaclass(CaseInsensitiv QUERY = "Query" HEADER = "Header" -class AppType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AppType(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: 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(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Status of an async operation. """ @@ -100,7 +99,7 @@ class AsyncOperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" FAILED = "Failed" -class AuthorizationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AuthorizationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): HEAD = "HEAD" OPTIONS = "OPTIONS" @@ -111,7 +110,14 @@ class AuthorizationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PATCH = "PATCH" DELETE = "DELETE" -class BackendProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AuthorizationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Authorization type options + """ + + #: OAuth2 authorization type. + O_AUTH2 = "OAuth2" + +class BackendProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Backend communication protocol. """ @@ -120,12 +126,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(str, Enum, metaclass=CaseInsensitiveEnumMeta): AUTHORIZATION_HEADER = "authorizationHeader" QUERY = "query" -class BearerTokenSendingMethods(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class BearerTokenSendingMethods(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Form of an authorization grant, which the client uses to request the access token. """ @@ -134,7 +140,7 @@ class BearerTokenSendingMethods(with_metaclass(CaseInsensitiveEnumMeta, str, Enu #: Access token will be transmitted as query parameters. QUERY = "query" -class CertificateConfigurationStoreName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CertificateConfigurationStoreName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The System.Security.Cryptography.x509certificates.StoreName certificate store location. Only Root and CertificateAuthority are valid locations. """ @@ -142,7 +148,7 @@ class CertificateConfigurationStoreName(with_metaclass(CaseInsensitiveEnumMeta, CERTIFICATE_AUTHORITY = "CertificateAuthority" ROOT = "Root" -class CertificateSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CertificateSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Certificate Source. """ @@ -151,7 +157,7 @@ class CertificateSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CUSTOM = "Custom" BUILT_IN = "BuiltIn" -class CertificateStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CertificateStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Certificate Status. """ @@ -159,18 +165,18 @@ class CertificateStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" IN_PROGRESS = "InProgress" -class ClientAuthenticationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ClientAuthenticationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: Basic Client Authentication method. BASIC = "Basic" #: Body based Authentication method. BODY = "Body" -class ConfigurationIdName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ConfigurationIdName(str, Enum, metaclass=CaseInsensitiveEnumMeta): CONFIGURATION = "configuration" -class Confirmation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Confirmation(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Determines the type of confirmation e-mail that will be sent to the newly created user. """ @@ -179,7 +185,7 @@ class Confirmation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Send an e-mail inviting the user to sign-up and complete registration. INVITE = "invite" -class ConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The connection status. """ @@ -188,7 +194,7 @@ class ConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DISCONNECTED = "Disconnected" DEGRADED = "Degraded" -class ConnectivityCheckProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ConnectivityCheckProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The request's protocol. Specific protocol configuration can be available based on this selection. The specified destination address must be coherent with this value. """ @@ -197,7 +203,7 @@ class ConnectivityCheckProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enu HTTP = "HTTP" HTTPS = "HTTPS" -class ConnectivityStatusType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ConnectivityStatusType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Resource Connectivity Status Type identifier. """ @@ -205,7 +211,7 @@ class ConnectivityStatusType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) SUCCESS = "success" FAILURE = "failure" -class ContentFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ContentFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Format of the Content in which the API is getting imported. """ @@ -232,7 +238,7 @@ class ContentFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The GraphQL API endpoint hosted on a publicly accessible internet address. GRAPHQL_LINK = "graphql-link" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource. """ @@ -241,7 +247,7 @@ class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DataMaskingMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DataMaskingMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Data masking mode. """ @@ -250,11 +256,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(str, Enum, metaclass=CaseInsensitiveEnumMeta): TRUE = "true" -class ExportFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExportFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: Export the Api Definition in OpenAPI 2.0 Specification as JSON document to the Storage Blob. SWAGGER = "swagger-link" @@ -268,7 +274,7 @@ class ExportFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Export the Api Definition in OpenAPI 3.0 Specification as JSON document to Storage Blob. OPENAPI_JSON = "openapi+json-link" -class ExportResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExportResultFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Format in which the API Details are exported to the Storage Blob with Sas Key valid for 5 minutes. """ @@ -283,7 +289,7 @@ class ExportResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Export the API Definition in OpenAPI Specification 3.0 to Storage Blob. OPEN_API = "openapi-link" -class GrantType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GrantType(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: Authorization Code Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.1. AUTHORIZATION_CODE = "authorizationCode" @@ -295,7 +301,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(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Group type. """ @@ -303,7 +309,7 @@ class GroupType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM = "system" EXTERNAL = "external" -class HostnameType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HostnameType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Hostname type. """ @@ -313,7 +319,7 @@ class HostnameType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SCM = "Scm" DEVELOPER_PORTAL = "DeveloperPortal" -class HttpCorrelationProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HttpCorrelationProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Sets correlation protocol to use for Application Insights diagnostics. """ @@ -325,7 +331,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(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: Facebook as Identity provider. FACEBOOK = "facebook" @@ -340,7 +346,7 @@ class IdentityProviderType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Azure Active Directory B2C as Identity provider. AAD_B2_C = "aadB2C" -class IssueType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IssueType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of issue. """ @@ -354,14 +360,14 @@ class IssueType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PORT_THROTTLED = "PortThrottled" PLATFORM = "Platform" -class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Key to be used to generate token for user. """ PRIMARY = "primary" SECONDARY = "secondary" -class LoggerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LoggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Logger type. """ @@ -372,14 +378,14 @@ class LoggerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Azure Monitor. AZURE_MONITOR = "azureMonitor" -class Method(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Method(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The HTTP method to be used. """ GET = "GET" POST = "POST" -class NameAvailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class NameAvailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Invalid indicates the name provided does not match the resource provider’s naming requirements (incorrect length, unsupported characters, etc.) AlreadyExists indicates that the name is already in use and is therefore unavailable. @@ -389,7 +395,7 @@ class NameAvailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class NotificationName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class NotificationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: The following email recipients and users will receive email notifications about subscription #: requests for API products requiring approval. @@ -412,7 +418,16 @@ 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 OAuth2GrantType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """OAuth2 grant type options + """ + + #: Authorization Code grant. + AUTHORIZATION_CODE = "AuthorizationCode" + #: Client Credential grant. + CLIENT_CREDENTIALS = "ClientCredentials" + +class OperationNameFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The format of the Operation Name for Application Insights telemetries. Default is Name. """ @@ -421,7 +436,7 @@ class OperationNameFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: HTTP_VERB URL. URL = "Url" -class Origin(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The origin of the issue. """ @@ -429,7 +444,7 @@ class Origin(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INBOUND = "Inbound" OUTBOUND = "Outbound" -class PlatformVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PlatformVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Compute Platform Version running the service. """ @@ -442,7 +457,7 @@ class PlatformVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Platform running the service on Multi Tenant V1 platform. MTV1 = "mtv1" -class PolicyContentFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PolicyContentFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Format of the policyContent. """ @@ -457,18 +472,25 @@ class PolicyContentFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Management service. RAWXML_LINK = "rawxml-link" -class PolicyExportFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PolicyExportFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: 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 PolicyFragmentContentFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + + #: 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(str, Enum, metaclass=CaseInsensitiveEnumMeta): POLICY = "policy" -class PolicyScopeContract(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PolicyScopeContract(str, Enum, metaclass=CaseInsensitiveEnumMeta): TENANT = "Tenant" PRODUCT = "Product" @@ -476,7 +498,7 @@ class PolicyScopeContract(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): OPERATION = "Operation" ALL = "All" -class PortalRevisionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PortalRevisionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Status of the portal's revision. """ @@ -489,13 +511,24 @@ class PortalRevisionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Portal's revision publishing failed. FAILED = "failed" -class PreferredIPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PortalSettingsCspMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The mode of the developer portal Content Security Policy (CSP). + """ + + #: The browser will block requests not matching allowed origins. + ENABLED = "enabled" + #: The browser will not apply the origin restrictions. + DISABLED = "disabled" + #: The browser will report requests not matching allowed origins without blocking them. + REPORT_ONLY = "reportOnly" + +class PreferredIPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The IP version to be used. Only IPv4 is supported for now. """ I_PV4 = "IPv4" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -504,7 +537,7 @@ class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveE DELETING = "Deleting" FAILED = "Failed" -class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The private endpoint connection status. """ @@ -512,7 +545,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumM APPROVED = "Approved" REJECTED = "Rejected" -class ProductState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProductState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible only to administrators. Default state of Product is notPublished. @@ -521,14 +554,14 @@ class ProductState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NOT_PUBLISHED = "notPublished" PUBLISHED = "published" -class Protocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Protocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): HTTP = "http" HTTPS = "https" WS = "ws" WSS = "wss" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Whether or not public endpoint access is allowed for this API Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled' @@ -537,7 +570,7 @@ class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ENABLED = "Enabled" DISABLED = "Disabled" -class ResourceSkuCapacityScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceSkuCapacityScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ @@ -548,14 +581,14 @@ class ResourceSkuCapacityScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, #: Scaling not supported. NONE = "none" -class SamplingType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SamplingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Sampling type. """ #: Fixed-rate sampling. FIXED = "fixed" -class SchemaType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SchemaType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Schema Type. Immutable. """ @@ -564,18 +597,18 @@ class SchemaType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Json schema type. JSON = "json" -class SettingsTypeName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SettingsTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): PUBLIC = "public" -class Severity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Severity(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The severity of the issue. """ ERROR = "Error" WARNING = "Warning" -class SkuType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Name of the Sku. """ @@ -592,7 +625,7 @@ class SkuType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Isolated SKU of Api Management. ISOLATED = "Isolated" -class SoapApiType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SoapApiType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of API to create. @@ -611,7 +644,7 @@ class SoapApiType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Imports the API having a GraphQL front end. GRAPH_QL = "graphql" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Status of the issue. """ @@ -626,7 +659,7 @@ class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The issue was closed. CLOSED = "closed" -class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SubscriptionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Subscription state. Possible states are * active – the subscription is active, * suspended – the subscription is blocked, and the subscriber cannot call any APIs of the product, * submitted – the subscription request has been made by the developer, but has not yet been @@ -642,7 +675,7 @@ class SubscriptionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): REJECTED = "rejected" CANCELLED = "cancelled" -class TemplateName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class TemplateName(str, Enum, metaclass=CaseInsensitiveEnumMeta): APPLICATION_APPROVED_NOTIFICATION_MESSAGE = "applicationApprovedNotificationMessage" ACCOUNT_CLOSED_DEVELOPER = "accountClosedDeveloper" @@ -659,7 +692,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(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Account state. Specifies whether the user is active or not. Blocked users are unable to sign into the developer portal or call any APIs of subscribed products. Default state is Active. """ @@ -673,7 +706,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(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The verbosity level applied to traces emitted by trace policies. """ @@ -687,7 +720,7 @@ class Verbosity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: diagnostic instance. ERROR = "error" -class VersioningScheme(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VersioningScheme(str, Enum, metaclass=CaseInsensitiveEnumMeta): """An value that determines where the API Version identifier will be located in a HTTP request. """ @@ -698,7 +731,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(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of VPN in which API Management service needs to be configured in. None (Default Value) means the API Management service is not part of any Virtual Network, External means the API Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models_py3.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models_py3.py index 37a29aafe06d..1892040ab78d 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 @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._api_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessInformationCollection(msrest.serialization.Model): @@ -21,7 +23,7 @@ class AccessInformationCollection(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Page values. - :vartype value: list[~api_management_client.models.AccessInformationContract] + :vartype value: list[~azure.mgmt.apimanagement.models.AccessInformationContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -295,7 +297,7 @@ class AdditionalLocation(msrest.serialization.Model): regions. :vartype location: str :ivar sku: Required. SKU properties of the API Management service. - :vartype sku: ~api_management_client.models.ApiManagementServiceSkuProperties + :vartype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties :ivar zones: A list of availability zones denoting where the resource needs to come from. :vartype zones: list[str] :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management @@ -312,15 +314,15 @@ class AdditionalLocation(msrest.serialization.Model): :vartype public_ip_address_id: str :ivar virtual_network_configuration: Virtual network configuration for the location. :vartype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :ivar gateway_regional_url: Gateway URL of the API Management service in the Region. :vartype gateway_regional_url: str :ivar disable_gateway: Property only valid for an Api Management service deployed in multiple locations. This can be used to disable the gateway in this additional location. :vartype disable_gateway: bool - :ivar platform_version: Compute Platform Version running the service. Possible values include: + :ivar platform_version: Compute Platform Version running the service. Known values are: "undetermined", "stv1", "stv2", "mtv1". - :vartype platform_version: str or ~api_management_client.models.PlatformVersion + :vartype platform_version: str or ~azure.mgmt.apimanagement.models.PlatformVersion """ _validation = { @@ -349,10 +351,10 @@ def __init__( self, *, location: str, - sku: "ApiManagementServiceSkuProperties", + sku: "_models.ApiManagementServiceSkuProperties", zones: Optional[List[str]] = None, public_ip_address_id: Optional[str] = None, - virtual_network_configuration: Optional["VirtualNetworkConfiguration"] = None, + virtual_network_configuration: Optional["_models.VirtualNetworkConfiguration"] = None, disable_gateway: Optional[bool] = False, **kwargs ): @@ -361,7 +363,7 @@ def __init__( regions. :paramtype location: str :keyword sku: Required. SKU properties of the API Management service. - :paramtype sku: ~api_management_client.models.ApiManagementServiceSkuProperties + :paramtype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties :keyword zones: A list of availability zones denoting where the resource needs to come from. :paramtype zones: list[str] :keyword public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with @@ -370,7 +372,7 @@ def __init__( :paramtype public_ip_address_id: str :keyword virtual_network_configuration: Virtual network configuration for the location. :paramtype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :keyword disable_gateway: Property only valid for an Api Management service deployed in multiple locations. This can be used to disable the gateway in this additional location. :paramtype disable_gateway: bool @@ -394,7 +396,7 @@ class ApiCollection(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Page values. - :vartype value: list[~api_management_client.models.ApiContract] + :vartype value: list[~azure.mgmt.apimanagement.models.ApiContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -485,12 +487,13 @@ class ApiContract(Resource): :ivar description: Description of the API. May include HTML formatting tags. :vartype description: str :ivar authentication_settings: Collection of authentication settings included into this API. - :vartype authentication_settings: ~api_management_client.models.AuthenticationSettingsContract + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :ivar subscription_key_parameter_names: Protocols over which API is made available. :vartype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "graphql". - :vartype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql". + :vartype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :ivar api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. :vartype api_revision: str @@ -513,9 +516,9 @@ class ApiContract(Resource): a URL. :vartype terms_of_service_url: str :ivar contact: Contact information for the API. - :vartype contact: ~api_management_client.models.ApiContactInformation + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :ivar license: License information for the API. - :vartype license: ~api_management_client.models.ApiLicenseInformation + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation :ivar source_api_id: API identifier of the source API. :vartype source_api_id: str :ivar display_name: API name. Must be 1 to 300 characters long. @@ -528,9 +531,9 @@ class ApiContract(Resource): the service instance creation to form a public URL for this API. :vartype path: str :ivar protocols: Describes on which protocols the operations in this API can be invoked. - :vartype protocols: list[str or ~api_management_client.models.Protocol] + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :ivar api_version_set: Version set details. - :vartype api_version_set: ~api_management_client.models.ApiVersionSetContractDetails + :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ _validation = { @@ -578,9 +581,9 @@ def __init__( self, *, description: Optional[str] = None, - authentication_settings: Optional["AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "ApiType"]] = None, + authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, + subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, + api_type: Optional[Union[str, "_models.ApiType"]] = None, api_revision: Optional[str] = None, api_version: Optional[str] = None, is_current: Optional[bool] = None, @@ -589,14 +592,14 @@ def __init__( api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, terms_of_service_url: Optional[str] = None, - contact: Optional["ApiContactInformation"] = None, - license: Optional["ApiLicenseInformation"] = None, + contact: Optional["_models.ApiContactInformation"] = None, + license: Optional["_models.ApiLicenseInformation"] = None, source_api_id: Optional[str] = None, display_name: Optional[str] = None, service_url: Optional[str] = None, path: Optional[str] = None, - protocols: Optional[List[Union[str, "Protocol"]]] = None, - api_version_set: Optional["ApiVersionSetContractDetails"] = None, + protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, + api_version_set: Optional["_models.ApiVersionSetContractDetails"] = None, **kwargs ): """ @@ -604,13 +607,12 @@ def __init__( :paramtype description: str :keyword authentication_settings: Collection of authentication settings included into this API. :paramtype authentication_settings: - ~api_management_client.models.AuthenticationSettingsContract + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", - "graphql". - :paramtype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql". + :paramtype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :keyword api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. :paramtype api_revision: str @@ -631,9 +633,9 @@ def __init__( of a URL. :paramtype terms_of_service_url: str :keyword contact: Contact information for the API. - :paramtype contact: ~api_management_client.models.ApiContactInformation + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :keyword license: License information for the API. - :paramtype license: ~api_management_client.models.ApiLicenseInformation + :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation :keyword source_api_id: API identifier of the source API. :paramtype source_api_id: str :keyword display_name: API name. Must be 1 to 300 characters long. @@ -646,9 +648,9 @@ def __init__( during the service instance creation to form a public URL for this API. :paramtype path: str :keyword protocols: Describes on which protocols the operations in this API can be invoked. - :paramtype protocols: list[str or ~api_management_client.models.Protocol] + :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :keyword api_version_set: Version set details. - :paramtype api_version_set: ~api_management_client.models.ApiVersionSetContractDetails + :paramtype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ super(ApiContract, self).__init__(**kwargs) self.description = description @@ -682,12 +684,13 @@ class ApiEntityBaseContract(msrest.serialization.Model): :ivar description: Description of the API. May include HTML formatting tags. :vartype description: str :ivar authentication_settings: Collection of authentication settings included into this API. - :vartype authentication_settings: ~api_management_client.models.AuthenticationSettingsContract + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :ivar subscription_key_parameter_names: Protocols over which API is made available. :vartype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "graphql". - :vartype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql". + :vartype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :ivar api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. :vartype api_revision: str @@ -710,9 +713,9 @@ class ApiEntityBaseContract(msrest.serialization.Model): a URL. :vartype terms_of_service_url: str :ivar contact: Contact information for the API. - :vartype contact: ~api_management_client.models.ApiContactInformation + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :ivar license: License information for the API. - :vartype license: ~api_management_client.models.ApiLicenseInformation + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation """ _validation = { @@ -745,9 +748,9 @@ def __init__( self, *, description: Optional[str] = None, - authentication_settings: Optional["AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "ApiType"]] = None, + authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, + subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, + api_type: Optional[Union[str, "_models.ApiType"]] = None, api_revision: Optional[str] = None, api_version: Optional[str] = None, is_current: Optional[bool] = None, @@ -756,8 +759,8 @@ def __init__( api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, terms_of_service_url: Optional[str] = None, - contact: Optional["ApiContactInformation"] = None, - license: Optional["ApiLicenseInformation"] = None, + contact: Optional["_models.ApiContactInformation"] = None, + license: Optional["_models.ApiLicenseInformation"] = None, **kwargs ): """ @@ -765,13 +768,12 @@ def __init__( :paramtype description: str :keyword authentication_settings: Collection of authentication settings included into this API. :paramtype authentication_settings: - ~api_management_client.models.AuthenticationSettingsContract + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", - "graphql". - :paramtype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql". + :paramtype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :keyword api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. :paramtype api_revision: str @@ -792,9 +794,9 @@ def __init__( of a URL. :paramtype terms_of_service_url: str :keyword contact: Contact information for the API. - :paramtype contact: ~api_management_client.models.ApiContactInformation + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :keyword license: License information for the API. - :paramtype license: ~api_management_client.models.ApiLicenseInformation + :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation """ super(ApiEntityBaseContract, self).__init__(**kwargs) self.description = description @@ -824,12 +826,13 @@ class ApiContractProperties(ApiEntityBaseContract): :ivar description: Description of the API. May include HTML formatting tags. :vartype description: str :ivar authentication_settings: Collection of authentication settings included into this API. - :vartype authentication_settings: ~api_management_client.models.AuthenticationSettingsContract + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :ivar subscription_key_parameter_names: Protocols over which API is made available. :vartype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "graphql". - :vartype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql". + :vartype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :ivar api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. :vartype api_revision: str @@ -852,9 +855,9 @@ class ApiContractProperties(ApiEntityBaseContract): a URL. :vartype terms_of_service_url: str :ivar contact: Contact information for the API. - :vartype contact: ~api_management_client.models.ApiContactInformation + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :ivar license: License information for the API. - :vartype license: ~api_management_client.models.ApiLicenseInformation + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation :ivar source_api_id: API identifier of the source API. :vartype source_api_id: str :ivar display_name: API name. Must be 1 to 300 characters long. @@ -867,9 +870,9 @@ class ApiContractProperties(ApiEntityBaseContract): 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 ~api_management_client.models.Protocol] + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :ivar api_version_set: Version set details. - :vartype api_version_set: ~api_management_client.models.ApiVersionSetContractDetails + :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ _validation = { @@ -912,9 +915,9 @@ def __init__( *, path: str, description: Optional[str] = None, - authentication_settings: Optional["AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "ApiType"]] = None, + authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, + subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, + api_type: Optional[Union[str, "_models.ApiType"]] = None, api_revision: Optional[str] = None, api_version: Optional[str] = None, is_current: Optional[bool] = None, @@ -923,13 +926,13 @@ def __init__( api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, terms_of_service_url: Optional[str] = None, - contact: Optional["ApiContactInformation"] = None, - license: Optional["ApiLicenseInformation"] = None, + contact: Optional["_models.ApiContactInformation"] = None, + license: Optional["_models.ApiLicenseInformation"] = None, source_api_id: Optional[str] = None, display_name: Optional[str] = None, service_url: Optional[str] = None, - protocols: Optional[List[Union[str, "Protocol"]]] = None, - api_version_set: Optional["ApiVersionSetContractDetails"] = None, + protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, + api_version_set: Optional["_models.ApiVersionSetContractDetails"] = None, **kwargs ): """ @@ -937,13 +940,12 @@ def __init__( :paramtype description: str :keyword authentication_settings: Collection of authentication settings included into this API. :paramtype authentication_settings: - ~api_management_client.models.AuthenticationSettingsContract + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", - "graphql". - :paramtype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql". + :paramtype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :keyword api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. :paramtype api_revision: str @@ -964,9 +966,9 @@ def __init__( of a URL. :paramtype terms_of_service_url: str :keyword contact: Contact information for the API. - :paramtype contact: ~api_management_client.models.ApiContactInformation + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :keyword license: License information for the API. - :paramtype license: ~api_management_client.models.ApiLicenseInformation + :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation :keyword source_api_id: API identifier of the source API. :paramtype source_api_id: str :keyword display_name: API name. Must be 1 to 300 characters long. @@ -979,9 +981,9 @@ def __init__( 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 ~api_management_client.models.Protocol] + :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :keyword api_version_set: Version set details. - :paramtype api_version_set: ~api_management_client.models.ApiVersionSetContractDetails + :paramtype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ super(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 @@ -1000,12 +1002,13 @@ class ApiContractUpdateProperties(ApiEntityBaseContract): :ivar description: Description of the API. May include HTML formatting tags. :vartype description: str :ivar authentication_settings: Collection of authentication settings included into this API. - :vartype authentication_settings: ~api_management_client.models.AuthenticationSettingsContract + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :ivar subscription_key_parameter_names: Protocols over which API is made available. :vartype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "graphql". - :vartype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql". + :vartype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :ivar api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. :vartype api_revision: str @@ -1028,9 +1031,9 @@ class ApiContractUpdateProperties(ApiEntityBaseContract): a URL. :vartype terms_of_service_url: str :ivar contact: Contact information for the API. - :vartype contact: ~api_management_client.models.ApiContactInformation + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :ivar license: License information for the API. - :vartype license: ~api_management_client.models.ApiLicenseInformation + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation :ivar display_name: API name. :vartype display_name: str :ivar service_url: Absolute URL of the backend service implementing this API. @@ -1040,7 +1043,7 @@ class ApiContractUpdateProperties(ApiEntityBaseContract): the service instance creation to form a public URL for this API. :vartype path: str :ivar protocols: Describes on which protocols the operations in this API can be invoked. - :vartype protocols: list[str or ~api_management_client.models.Protocol] + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] """ _validation = { @@ -1080,9 +1083,9 @@ def __init__( self, *, description: Optional[str] = None, - authentication_settings: Optional["AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "ApiType"]] = None, + authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, + subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, + api_type: Optional[Union[str, "_models.ApiType"]] = None, api_revision: Optional[str] = None, api_version: Optional[str] = None, is_current: Optional[bool] = None, @@ -1091,12 +1094,12 @@ def __init__( api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, terms_of_service_url: Optional[str] = None, - contact: Optional["ApiContactInformation"] = None, - license: Optional["ApiLicenseInformation"] = None, + contact: Optional["_models.ApiContactInformation"] = None, + license: Optional["_models.ApiLicenseInformation"] = None, display_name: Optional[str] = None, service_url: Optional[str] = None, path: Optional[str] = None, - protocols: Optional[List[Union[str, "Protocol"]]] = None, + protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, **kwargs ): """ @@ -1104,13 +1107,12 @@ def __init__( :paramtype description: str :keyword authentication_settings: Collection of authentication settings included into this API. :paramtype authentication_settings: - ~api_management_client.models.AuthenticationSettingsContract + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", - "graphql". - :paramtype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql". + :paramtype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :keyword api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. :paramtype api_revision: str @@ -1131,9 +1133,9 @@ def __init__( of a URL. :paramtype terms_of_service_url: str :keyword contact: Contact information for the API. - :paramtype contact: ~api_management_client.models.ApiContactInformation + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :keyword license: License information for the API. - :paramtype license: ~api_management_client.models.ApiLicenseInformation + :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation :keyword display_name: API name. :paramtype display_name: str :keyword service_url: Absolute URL of the backend service implementing this API. @@ -1143,7 +1145,7 @@ def __init__( during the service instance creation to form a public URL for this API. :paramtype path: str :keyword protocols: Describes on which protocols the operations in this API can be invoked. - :paramtype protocols: list[str or ~api_management_client.models.Protocol] + :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] """ super(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 @@ -1160,12 +1162,13 @@ class ApiCreateOrUpdateParameter(msrest.serialization.Model): :ivar description: Description of the API. May include HTML formatting tags. :vartype description: str :ivar authentication_settings: Collection of authentication settings included into this API. - :vartype authentication_settings: ~api_management_client.models.AuthenticationSettingsContract + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :ivar subscription_key_parameter_names: Protocols over which API is made available. :vartype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "graphql". - :vartype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql". + :vartype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :ivar api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. :vartype api_revision: str @@ -1188,9 +1191,9 @@ class ApiCreateOrUpdateParameter(msrest.serialization.Model): a URL. :vartype terms_of_service_url: str :ivar contact: Contact information for the API. - :vartype contact: ~api_management_client.models.ApiContactInformation + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :ivar license: License information for the API. - :vartype license: ~api_management_client.models.ApiLicenseInformation + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation :ivar source_api_id: API identifier of the source API. :vartype source_api_id: str :ivar display_name: API name. Must be 1 to 300 characters long. @@ -1203,26 +1206,26 @@ class ApiCreateOrUpdateParameter(msrest.serialization.Model): the service instance creation to form a public URL for this API. :vartype path: str :ivar protocols: Describes on which protocols the operations in this API can be invoked. - :vartype protocols: list[str or ~api_management_client.models.Protocol] + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :ivar api_version_set: Version set details. - :vartype api_version_set: ~api_management_client.models.ApiVersionSetContractDetails + :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails :ivar value: Content value when Importing an API. :vartype value: str - :ivar format: Format of the Content in which the API is getting imported. Possible values - include: "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", - "wsdl-link", "openapi", "openapi+json", "openapi-link", "openapi+json-link", "graphql-link". - :vartype format: str or ~api_management_client.models.ContentFormat + :ivar format: Format of the Content in which the API is getting imported. Known values are: + "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", "wsdl-link", + "openapi", "openapi+json", "openapi-link", "openapi+json-link", "graphql-link". + :vartype format: str or ~azure.mgmt.apimanagement.models.ContentFormat :ivar wsdl_selector: Criteria to limit import of WSDL to a subset of the document. - :vartype wsdl_selector: ~api_management_client.models.ApiCreateOrUpdatePropertiesWsdlSelector + :vartype wsdl_selector: + ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector :ivar soap_api_type: Type of API to create. * ``http`` creates a REST API * ``soap`` creates a SOAP pass-through API * ``websocket`` creates websocket API - * ``graphql`` creates GraphQL API. Possible values include: "http", "soap", "websocket", - "graphql". - :vartype soap_api_type: str or ~api_management_client.models.SoapApiType + * ``graphql`` creates GraphQL API. Known values are: "http", "soap", "websocket", "graphql". + :vartype soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType """ _validation = { @@ -1268,9 +1271,9 @@ def __init__( self, *, description: Optional[str] = None, - authentication_settings: Optional["AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "ApiType"]] = None, + authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, + subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, + api_type: Optional[Union[str, "_models.ApiType"]] = None, api_revision: Optional[str] = None, api_version: Optional[str] = None, is_current: Optional[bool] = None, @@ -1279,18 +1282,18 @@ def __init__( api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, terms_of_service_url: Optional[str] = None, - contact: Optional["ApiContactInformation"] = None, - license: Optional["ApiLicenseInformation"] = None, + contact: Optional["_models.ApiContactInformation"] = None, + license: Optional["_models.ApiLicenseInformation"] = None, source_api_id: Optional[str] = None, display_name: Optional[str] = None, service_url: Optional[str] = None, path: Optional[str] = None, - protocols: Optional[List[Union[str, "Protocol"]]] = None, - api_version_set: Optional["ApiVersionSetContractDetails"] = None, + protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, + api_version_set: Optional["_models.ApiVersionSetContractDetails"] = None, value: Optional[str] = None, - format: Optional[Union[str, "ContentFormat"]] = None, - wsdl_selector: Optional["ApiCreateOrUpdatePropertiesWsdlSelector"] = None, - soap_api_type: Optional[Union[str, "SoapApiType"]] = None, + format: Optional[Union[str, "_models.ContentFormat"]] = None, + wsdl_selector: Optional["_models.ApiCreateOrUpdatePropertiesWsdlSelector"] = None, + soap_api_type: Optional[Union[str, "_models.SoapApiType"]] = None, **kwargs ): """ @@ -1298,13 +1301,12 @@ def __init__( :paramtype description: str :keyword authentication_settings: Collection of authentication settings included into this API. :paramtype authentication_settings: - ~api_management_client.models.AuthenticationSettingsContract + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", - "graphql". - :paramtype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql". + :paramtype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :keyword api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. :paramtype api_revision: str @@ -1325,9 +1327,9 @@ def __init__( of a URL. :paramtype terms_of_service_url: str :keyword contact: Contact information for the API. - :paramtype contact: ~api_management_client.models.ApiContactInformation + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :keyword license: License information for the API. - :paramtype license: ~api_management_client.models.ApiLicenseInformation + :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation :keyword source_api_id: API identifier of the source API. :paramtype source_api_id: str :keyword display_name: API name. Must be 1 to 300 characters long. @@ -1340,26 +1342,26 @@ def __init__( during the service instance creation to form a public URL for this API. :paramtype path: str :keyword protocols: Describes on which protocols the operations in this API can be invoked. - :paramtype protocols: list[str or ~api_management_client.models.Protocol] + :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :keyword api_version_set: Version set details. - :paramtype api_version_set: ~api_management_client.models.ApiVersionSetContractDetails + :paramtype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails :keyword value: Content value when Importing an API. :paramtype value: str - :keyword format: Format of the Content in which the API is getting imported. Possible values - include: "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", - "wsdl-link", "openapi", "openapi+json", "openapi-link", "openapi+json-link", "graphql-link". - :paramtype format: str or ~api_management_client.models.ContentFormat + :keyword format: Format of the Content in which the API is getting imported. Known values are: + "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", "wsdl-link", + "openapi", "openapi+json", "openapi-link", "openapi+json-link", "graphql-link". + :paramtype format: str or ~azure.mgmt.apimanagement.models.ContentFormat :keyword wsdl_selector: Criteria to limit import of WSDL to a subset of the document. - :paramtype wsdl_selector: ~api_management_client.models.ApiCreateOrUpdatePropertiesWsdlSelector + :paramtype wsdl_selector: + ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector :keyword soap_api_type: Type of API to create. * ``http`` creates a REST API * ``soap`` creates a SOAP pass-through API * ``websocket`` creates websocket API - * ``graphql`` creates GraphQL API. Possible values include: "http", "soap", "websocket", - "graphql". - :paramtype soap_api_type: str or ~api_management_client.models.SoapApiType + * ``graphql`` creates GraphQL API. Known values are: "http", "soap", "websocket", "graphql". + :paramtype soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType """ super(ApiCreateOrUpdateParameter, self).__init__(**kwargs) self.description = description @@ -1399,12 +1401,13 @@ class ApiCreateOrUpdateProperties(ApiContractProperties): :ivar description: Description of the API. May include HTML formatting tags. :vartype description: str :ivar authentication_settings: Collection of authentication settings included into this API. - :vartype authentication_settings: ~api_management_client.models.AuthenticationSettingsContract + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :ivar subscription_key_parameter_names: Protocols over which API is made available. :vartype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "graphql". - :vartype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql". + :vartype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :ivar api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. :vartype api_revision: str @@ -1427,9 +1430,9 @@ class ApiCreateOrUpdateProperties(ApiContractProperties): a URL. :vartype terms_of_service_url: str :ivar contact: Contact information for the API. - :vartype contact: ~api_management_client.models.ApiContactInformation + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :ivar license: License information for the API. - :vartype license: ~api_management_client.models.ApiLicenseInformation + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation :ivar source_api_id: API identifier of the source API. :vartype source_api_id: str :ivar display_name: API name. Must be 1 to 300 characters long. @@ -1442,26 +1445,26 @@ class ApiCreateOrUpdateProperties(ApiContractProperties): 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 ~api_management_client.models.Protocol] + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :ivar api_version_set: Version set details. - :vartype api_version_set: ~api_management_client.models.ApiVersionSetContractDetails + :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails :ivar value: Content value when Importing an API. :vartype value: str - :ivar format: Format of the Content in which the API is getting imported. Possible values - include: "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", - "wsdl-link", "openapi", "openapi+json", "openapi-link", "openapi+json-link", "graphql-link". - :vartype format: str or ~api_management_client.models.ContentFormat + :ivar format: Format of the Content in which the API is getting imported. Known values are: + "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", "wsdl-link", + "openapi", "openapi+json", "openapi-link", "openapi+json-link", "graphql-link". + :vartype format: str or ~azure.mgmt.apimanagement.models.ContentFormat :ivar wsdl_selector: Criteria to limit import of WSDL to a subset of the document. - :vartype wsdl_selector: ~api_management_client.models.ApiCreateOrUpdatePropertiesWsdlSelector + :vartype wsdl_selector: + ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector :ivar soap_api_type: Type of API to create. * ``http`` creates a REST API * ``soap`` creates a SOAP pass-through API * ``websocket`` creates websocket API - * ``graphql`` creates GraphQL API. Possible values include: "http", "soap", "websocket", - "graphql". - :vartype soap_api_type: str or ~api_management_client.models.SoapApiType + * ``graphql`` creates GraphQL API. Known values are: "http", "soap", "websocket", "graphql". + :vartype soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType """ _validation = { @@ -1508,9 +1511,9 @@ def __init__( *, path: str, description: Optional[str] = None, - authentication_settings: Optional["AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "ApiType"]] = None, + authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, + subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, + api_type: Optional[Union[str, "_models.ApiType"]] = None, api_revision: Optional[str] = None, api_version: Optional[str] = None, is_current: Optional[bool] = None, @@ -1519,17 +1522,17 @@ def __init__( api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, terms_of_service_url: Optional[str] = None, - contact: Optional["ApiContactInformation"] = None, - license: Optional["ApiLicenseInformation"] = None, + contact: Optional["_models.ApiContactInformation"] = None, + license: Optional["_models.ApiLicenseInformation"] = None, source_api_id: Optional[str] = None, display_name: Optional[str] = None, service_url: Optional[str] = None, - protocols: Optional[List[Union[str, "Protocol"]]] = None, - api_version_set: Optional["ApiVersionSetContractDetails"] = None, + protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, + api_version_set: Optional["_models.ApiVersionSetContractDetails"] = None, value: Optional[str] = None, - format: Optional[Union[str, "ContentFormat"]] = None, - wsdl_selector: Optional["ApiCreateOrUpdatePropertiesWsdlSelector"] = None, - soap_api_type: Optional[Union[str, "SoapApiType"]] = None, + format: Optional[Union[str, "_models.ContentFormat"]] = None, + wsdl_selector: Optional["_models.ApiCreateOrUpdatePropertiesWsdlSelector"] = None, + soap_api_type: Optional[Union[str, "_models.SoapApiType"]] = None, **kwargs ): """ @@ -1537,13 +1540,12 @@ def __init__( :paramtype description: str :keyword authentication_settings: Collection of authentication settings included into this API. :paramtype authentication_settings: - ~api_management_client.models.AuthenticationSettingsContract + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", - "graphql". - :paramtype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql". + :paramtype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :keyword api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. :paramtype api_revision: str @@ -1564,9 +1566,9 @@ def __init__( of a URL. :paramtype terms_of_service_url: str :keyword contact: Contact information for the API. - :paramtype contact: ~api_management_client.models.ApiContactInformation + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :keyword license: License information for the API. - :paramtype license: ~api_management_client.models.ApiLicenseInformation + :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation :keyword source_api_id: API identifier of the source API. :paramtype source_api_id: str :keyword display_name: API name. Must be 1 to 300 characters long. @@ -1579,26 +1581,26 @@ def __init__( 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 ~api_management_client.models.Protocol] + :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] :keyword api_version_set: Version set details. - :paramtype api_version_set: ~api_management_client.models.ApiVersionSetContractDetails + :paramtype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails :keyword value: Content value when Importing an API. :paramtype value: str - :keyword format: Format of the Content in which the API is getting imported. Possible values - include: "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", - "wsdl-link", "openapi", "openapi+json", "openapi-link", "openapi+json-link", "graphql-link". - :paramtype format: str or ~api_management_client.models.ContentFormat + :keyword format: Format of the Content in which the API is getting imported. Known values are: + "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", "wsdl-link", + "openapi", "openapi+json", "openapi-link", "openapi+json-link", "graphql-link". + :paramtype format: str or ~azure.mgmt.apimanagement.models.ContentFormat :keyword wsdl_selector: Criteria to limit import of WSDL to a subset of the document. - :paramtype wsdl_selector: ~api_management_client.models.ApiCreateOrUpdatePropertiesWsdlSelector + :paramtype wsdl_selector: + ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector :keyword soap_api_type: Type of API to create. * ``http`` creates a REST API * ``soap`` creates a SOAP pass-through API * ``websocket`` creates websocket API - * ``graphql`` creates GraphQL API. Possible values include: "http", "soap", "websocket", - "graphql". - :paramtype soap_api_type: str or ~api_management_client.models.SoapApiType + * ``graphql`` creates GraphQL API. Known values are: "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 @@ -1645,11 +1647,11 @@ class ApiExportResult(msrest.serialization.Model): :ivar id: ResourceId of the API which was exported. :vartype id: str :ivar export_result_format: Format in which the API Details are exported to the Storage Blob - with Sas Key valid for 5 minutes. Possible values include: "swagger-link-json", - "wsdl-link+xml", "wadl-link-json", "openapi-link". - :vartype export_result_format: str or ~api_management_client.models.ExportResultFormat + with Sas Key valid for 5 minutes. Known values are: "swagger-link-json", "wsdl-link+xml", + "wadl-link-json", "openapi-link". + :vartype export_result_format: str or ~azure.mgmt.apimanagement.models.ExportResultFormat :ivar value: The object defining the schema of the exported API Detail. - :vartype value: ~api_management_client.models.ApiExportResultValue + :vartype value: ~azure.mgmt.apimanagement.models.ApiExportResultValue """ _attribute_map = { @@ -1662,19 +1664,19 @@ def __init__( self, *, id: Optional[str] = None, - export_result_format: Optional[Union[str, "ExportResultFormat"]] = None, - value: Optional["ApiExportResultValue"] = None, + export_result_format: Optional[Union[str, "_models.ExportResultFormat"]] = None, + value: Optional["_models.ApiExportResultValue"] = None, **kwargs ): """ :keyword id: ResourceId of the API which was exported. :paramtype id: str :keyword export_result_format: Format in which the API Details are exported to the Storage Blob - with Sas Key valid for 5 minutes. Possible values include: "swagger-link-json", - "wsdl-link+xml", "wadl-link-json", "openapi-link". - :paramtype export_result_format: str or ~api_management_client.models.ExportResultFormat + with Sas Key valid for 5 minutes. Known values are: "swagger-link-json", "wsdl-link+xml", + "wadl-link-json", "openapi-link". + :paramtype export_result_format: str or ~azure.mgmt.apimanagement.models.ExportResultFormat :keyword value: The object defining the schema of the exported API Detail. - :paramtype value: ~api_management_client.models.ApiExportResultValue + :paramtype value: ~azure.mgmt.apimanagement.models.ApiExportResultValue """ super(ApiExportResult, self).__init__(**kwargs) self.id = id @@ -1781,10 +1783,10 @@ class ApiManagementServiceBackupRestoreParameters(msrest.serialization.Model): :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 ~api_management_client.models.AccessType + :ivar access_type: The type of access to be used for the storage account. Known values are: + "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 @@ -1814,7 +1816,7 @@ def __init__( storage_account: str, container_name: str, backup_name: str, - access_type: Optional[Union[str, "AccessType"]] = "AccessKey", + access_type: Optional[Union[str, "_models.AccessType"]] = "AccessKey", access_key: Optional[str] = None, client_id: Optional[str] = None, **kwargs @@ -1828,10 +1830,10 @@ def __init__( :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 ~api_management_client.models.AccessType + :keyword access_type: The type of access to be used for the storage account. Known values are: + "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 @@ -1878,7 +1880,7 @@ class ApiManagementServiceBaseProperties(msrest.serialization.Model): :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. :vartype developer_portal_url: str :ivar hostname_configurations: Custom hostname configuration of the API Management service. - :vartype hostname_configurations: list[~api_management_client.models.HostnameConfiguration] + :vartype hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. :vartype public_ip_addresses: list[str] @@ -1893,14 +1895,14 @@ class ApiManagementServiceBaseProperties(msrest.serialization.Model): :ivar public_network_access: Whether or not public endpoint access is allowed for this API Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. - Possible values include: "Enabled", "Disabled". - :vartype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled", "Disabled". + :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :ivar virtual_network_configuration: Virtual network configuration of the API Management service. :vartype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :ivar additional_locations: Additional datacenter locations of the API Management service. - :vartype additional_locations: list[~api_management_client.models.AdditionalLocation] + :vartype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] :ivar custom_properties: Custom properties of the API Management service.
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting @@ -1931,7 +1933,7 @@ class ApiManagementServiceBaseProperties(msrest.serialization.Model): :vartype custom_properties: dict[str, str] :ivar certificates: List of Certificates that need to be installed in the API Management service. Max supported certificates that can be installed is 10. - :vartype certificates: list[~api_management_client.models.CertificateConfiguration] + :vartype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] :ivar enable_client_certificate: Property only meant to be used for Consumption SKU Service. This enforces a client certificate to be presented on each request to the gateway. This also enables the ability to authenticate the certificate in the policy on the gateway. @@ -1943,21 +1945,21 @@ class ApiManagementServiceBaseProperties(msrest.serialization.Model): configured in. None (Default Value) means the API Management service is not part of any Virtual Network, External means the API Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside - a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", + a Virtual Network having an Intranet Facing Endpoint only. Known values are: "None", "External", "Internal". Default value: "None". - :vartype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + :vartype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType :ivar api_version_constraint: Control Plane Apis version constraint for the API Management service. - :vartype api_version_constraint: ~api_management_client.models.ApiVersionConstraint + :vartype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint :ivar restore: Undelete Api Management Service if it was previously soft-deleted. If this flag is specified and set to True all other properties will be ignored. :vartype restore: bool :ivar private_endpoint_connections: List of Private Endpoint Connections of this service. :vartype private_endpoint_connections: - list[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] - :ivar platform_version: Compute Platform Version running the service in this location. Possible - values include: "undetermined", "stv1", "stv2", "mtv1". - :vartype platform_version: str or ~api_management_client.models.PlatformVersion + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :ivar platform_version: Compute Platform Version running the service in this location. Known + values are: "undetermined", "stv1", "stv2", "mtv1". + :vartype platform_version: str or ~azure.mgmt.apimanagement.models.PlatformVersion """ _validation = { @@ -2009,26 +2011,27 @@ def __init__( self, *, notification_sender_email: Optional[str] = None, - hostname_configurations: Optional[List["HostnameConfiguration"]] = None, + hostname_configurations: Optional[List["_models.HostnameConfiguration"]] = None, public_ip_address_id: Optional[str] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - virtual_network_configuration: Optional["VirtualNetworkConfiguration"] = None, - additional_locations: Optional[List["AdditionalLocation"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + virtual_network_configuration: Optional["_models.VirtualNetworkConfiguration"] = None, + additional_locations: Optional[List["_models.AdditionalLocation"]] = None, custom_properties: Optional[Dict[str, str]] = None, - certificates: Optional[List["CertificateConfiguration"]] = None, + certificates: Optional[List["_models.CertificateConfiguration"]] = None, enable_client_certificate: Optional[bool] = False, disable_gateway: Optional[bool] = False, - virtual_network_type: Optional[Union[str, "VirtualNetworkType"]] = "None", - api_version_constraint: Optional["ApiVersionConstraint"] = None, + virtual_network_type: Optional[Union[str, "_models.VirtualNetworkType"]] = "None", + api_version_constraint: Optional["_models.ApiVersionConstraint"] = None, restore: Optional[bool] = False, - private_endpoint_connections: Optional[List["RemotePrivateEndpointConnectionWrapper"]] = None, + private_endpoint_connections: Optional[List["_models.RemotePrivateEndpointConnectionWrapper"]] = None, **kwargs ): """ :keyword notification_sender_email: Email address from which the notification will be sent. :paramtype notification_sender_email: str :keyword hostname_configurations: Custom hostname configuration of the API Management service. - :paramtype hostname_configurations: list[~api_management_client.models.HostnameConfiguration] + :paramtype hostname_configurations: + list[~azure.mgmt.apimanagement.models.HostnameConfiguration] :keyword public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with Virtual Network deployed service in the region. Supported only for Developer and Premium SKU being deployed in Virtual Network. @@ -2036,14 +2039,14 @@ def __init__( :keyword public_network_access: Whether or not public endpoint access is allowed for this API Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. - Possible values include: "Enabled", "Disabled". - :paramtype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled", "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :keyword virtual_network_configuration: Virtual network configuration of the API Management service. :paramtype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :keyword additional_locations: Additional datacenter locations of the API Management service. - :paramtype additional_locations: list[~api_management_client.models.AdditionalLocation] + :paramtype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] :keyword custom_properties: Custom properties of the API Management service.
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting @@ -2074,7 +2077,7 @@ def __init__( :paramtype custom_properties: dict[str, str] :keyword certificates: List of Certificates that need to be installed in the API Management service. Max supported certificates that can be installed is 10. - :paramtype certificates: list[~api_management_client.models.CertificateConfiguration] + :paramtype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] :keyword enable_client_certificate: Property only meant to be used for Consumption SKU Service. This enforces a client certificate to be presented on each request to the gateway. This also enables the ability to authenticate the certificate in the policy on the gateway. @@ -2086,18 +2089,18 @@ def __init__( configured in. None (Default Value) means the API Management service is not part of any Virtual Network, External means the API Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside - a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", + a Virtual Network having an Intranet Facing Endpoint only. Known values are: "None", "External", "Internal". Default value: "None". - :paramtype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + :paramtype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType :keyword api_version_constraint: Control Plane Apis version constraint for the API Management service. - :paramtype api_version_constraint: ~api_management_client.models.ApiVersionConstraint + :paramtype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint :keyword restore: Undelete Api Management Service if it was previously soft-deleted. If this flag is specified and set to True all other properties will be ignored. :paramtype restore: bool :keyword private_endpoint_connections: List of Private Endpoint Connections of this service. :paramtype private_endpoint_connections: - list[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] """ super(ApiManagementServiceBaseProperties, self).__init__(**kwargs) self.notification_sender_email = notification_sender_email @@ -2220,9 +2223,9 @@ class ApiManagementServiceIdentity(msrest.serialization.Model): :ivar type: Required. The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the service. Possible values - include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :vartype type: str or ~api_management_client.models.ApimIdentityType + identities. The type 'None' will remove any identities from the service. Known values are: + "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + :vartype type: str or ~azure.mgmt.apimanagement.models.ApimIdentityType :ivar principal_id: The principal id of the identity. :vartype principal_id: str :ivar tenant_id: The client tenant id of the identity. @@ -2233,7 +2236,7 @@ class ApiManagementServiceIdentity(msrest.serialization.Model): '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. :vartype user_assigned_identities: dict[str, - ~api_management_client.models.UserIdentityProperties] + ~azure.mgmt.apimanagement.models.UserIdentityProperties] """ _validation = { @@ -2252,23 +2255,23 @@ class ApiManagementServiceIdentity(msrest.serialization.Model): def __init__( self, *, - type: Union[str, "ApimIdentityType"], - user_assigned_identities: Optional[Dict[str, "UserIdentityProperties"]] = None, + type: Union[str, "_models.ApimIdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, **kwargs ): """ :keyword type: Required. The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the service. Possible values - include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :paramtype type: str or ~api_management_client.models.ApimIdentityType + identities. The type 'None' will remove any identities from the service. Known values are: + "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, - ~api_management_client.models.UserIdentityProperties] + ~azure.mgmt.apimanagement.models.UserIdentityProperties] """ super(ApiManagementServiceIdentity, self).__init__(**kwargs) self.type = type @@ -2283,7 +2286,7 @@ class ApiManagementServiceListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar value: Required. Result of the List API Management services operation. - :vartype value: list[~api_management_client.models.ApiManagementServiceResource] + :vartype value: list[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of API Management services. :vartype next_link: str @@ -2301,13 +2304,13 @@ class ApiManagementServiceListResult(msrest.serialization.Model): def __init__( self, *, - value: List["ApiManagementServiceResource"], + value: List["_models.ApiManagementServiceResource"], next_link: Optional[str] = None, **kwargs ): """ :keyword value: Required. Result of the List API Management services operation. - :paramtype value: list[~api_management_client.models.ApiManagementServiceResource] + :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 @@ -2332,9 +2335,9 @@ class ApiManagementServiceNameAvailabilityResult(msrest.serialization.Model): :vartype message: str :ivar reason: Invalid indicates the name provided does not match the resource provider’s naming requirements (incorrect length, unsupported characters, etc.) AlreadyExists indicates that the - name is already in use and is therefore unavailable. Possible values include: "Valid", - "Invalid", "AlreadyExists". - :vartype reason: str or ~api_management_client.models.NameAvailabilityReason + name is already in use and is therefore unavailable. Known values are: "Valid", "Invalid", + "AlreadyExists". + :vartype reason: str or ~azure.mgmt.apimanagement.models.NameAvailabilityReason """ _validation = { @@ -2351,15 +2354,15 @@ class ApiManagementServiceNameAvailabilityResult(msrest.serialization.Model): def __init__( self, *, - reason: Optional[Union[str, "NameAvailabilityReason"]] = None, + reason: Optional[Union[str, "_models.NameAvailabilityReason"]] = None, **kwargs ): """ :keyword reason: Invalid indicates the name provided does not match the resource provider’s naming requirements (incorrect length, unsupported characters, etc.) AlreadyExists indicates - that the name is already in use and is therefore unavailable. Possible values include: "Valid", + that the name is already in use and is therefore unavailable. Known values are: "Valid", "Invalid", "AlreadyExists". - :paramtype reason: str or ~api_management_client.models.NameAvailabilityReason + :paramtype reason: str or ~azure.mgmt.apimanagement.models.NameAvailabilityReason """ super(ApiManagementServiceNameAvailabilityResult, self).__init__(**kwargs) self.name_available = None @@ -2399,7 +2402,7 @@ class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. :vartype developer_portal_url: str :ivar hostname_configurations: Custom hostname configuration of the API Management service. - :vartype hostname_configurations: list[~api_management_client.models.HostnameConfiguration] + :vartype hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. :vartype public_ip_addresses: list[str] @@ -2414,14 +2417,14 @@ class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): :ivar public_network_access: Whether or not public endpoint access is allowed for this API Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. - Possible values include: "Enabled", "Disabled". - :vartype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled", "Disabled". + :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :ivar virtual_network_configuration: Virtual network configuration of the API Management service. :vartype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :ivar additional_locations: Additional datacenter locations of the API Management service. - :vartype additional_locations: list[~api_management_client.models.AdditionalLocation] + :vartype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] :ivar custom_properties: Custom properties of the API Management service.
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting @@ -2452,7 +2455,7 @@ class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): :vartype custom_properties: dict[str, str] :ivar certificates: List of Certificates that need to be installed in the API Management service. Max supported certificates that can be installed is 10. - :vartype certificates: list[~api_management_client.models.CertificateConfiguration] + :vartype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] :ivar enable_client_certificate: Property only meant to be used for Consumption SKU Service. This enforces a client certificate to be presented on each request to the gateway. This also enables the ability to authenticate the certificate in the policy on the gateway. @@ -2464,21 +2467,21 @@ class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): configured in. None (Default Value) means the API Management service is not part of any Virtual Network, External means the API Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside - a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", + a Virtual Network having an Intranet Facing Endpoint only. Known values are: "None", "External", "Internal". Default value: "None". - :vartype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + :vartype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType :ivar api_version_constraint: Control Plane Apis version constraint for the API Management service. - :vartype api_version_constraint: ~api_management_client.models.ApiVersionConstraint + :vartype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint :ivar restore: Undelete Api Management Service if it was previously soft-deleted. If this flag is specified and set to True all other properties will be ignored. :vartype restore: bool :ivar private_endpoint_connections: List of Private Endpoint Connections of this service. :vartype private_endpoint_connections: - list[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] - :ivar platform_version: Compute Platform Version running the service in this location. Possible - values include: "undetermined", "stv1", "stv2", "mtv1". - :vartype platform_version: str or ~api_management_client.models.PlatformVersion + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :ivar platform_version: Compute Platform Version running the service in this location. Known + values are: "undetermined", "stv1", "stv2", "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. @@ -2540,26 +2543,27 @@ def __init__( publisher_email: str, publisher_name: str, notification_sender_email: Optional[str] = None, - hostname_configurations: Optional[List["HostnameConfiguration"]] = None, + hostname_configurations: Optional[List["_models.HostnameConfiguration"]] = None, public_ip_address_id: Optional[str] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - virtual_network_configuration: Optional["VirtualNetworkConfiguration"] = None, - additional_locations: Optional[List["AdditionalLocation"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + virtual_network_configuration: Optional["_models.VirtualNetworkConfiguration"] = None, + additional_locations: Optional[List["_models.AdditionalLocation"]] = None, custom_properties: Optional[Dict[str, str]] = None, - certificates: Optional[List["CertificateConfiguration"]] = None, + certificates: Optional[List["_models.CertificateConfiguration"]] = None, enable_client_certificate: Optional[bool] = False, disable_gateway: Optional[bool] = False, - virtual_network_type: Optional[Union[str, "VirtualNetworkType"]] = "None", - api_version_constraint: Optional["ApiVersionConstraint"] = None, + virtual_network_type: Optional[Union[str, "_models.VirtualNetworkType"]] = "None", + api_version_constraint: Optional["_models.ApiVersionConstraint"] = None, restore: Optional[bool] = False, - private_endpoint_connections: Optional[List["RemotePrivateEndpointConnectionWrapper"]] = None, + private_endpoint_connections: Optional[List["_models.RemotePrivateEndpointConnectionWrapper"]] = None, **kwargs ): """ :keyword notification_sender_email: Email address from which the notification will be sent. :paramtype notification_sender_email: str :keyword hostname_configurations: Custom hostname configuration of the API Management service. - :paramtype hostname_configurations: list[~api_management_client.models.HostnameConfiguration] + :paramtype hostname_configurations: + list[~azure.mgmt.apimanagement.models.HostnameConfiguration] :keyword public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with Virtual Network deployed service in the region. Supported only for Developer and Premium SKU being deployed in Virtual Network. @@ -2567,14 +2571,14 @@ def __init__( :keyword public_network_access: Whether or not public endpoint access is allowed for this API Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. - Possible values include: "Enabled", "Disabled". - :paramtype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled", "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :keyword virtual_network_configuration: Virtual network configuration of the API Management service. :paramtype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :keyword additional_locations: Additional datacenter locations of the API Management service. - :paramtype additional_locations: list[~api_management_client.models.AdditionalLocation] + :paramtype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] :keyword custom_properties: Custom properties of the API Management service.
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting @@ -2605,7 +2609,7 @@ def __init__( :paramtype custom_properties: dict[str, str] :keyword certificates: List of Certificates that need to be installed in the API Management service. Max supported certificates that can be installed is 10. - :paramtype certificates: list[~api_management_client.models.CertificateConfiguration] + :paramtype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] :keyword enable_client_certificate: Property only meant to be used for Consumption SKU Service. This enforces a client certificate to be presented on each request to the gateway. This also enables the ability to authenticate the certificate in the policy on the gateway. @@ -2617,18 +2621,18 @@ def __init__( configured in. None (Default Value) means the API Management service is not part of any Virtual Network, External means the API Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside - a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", + a Virtual Network having an Intranet Facing Endpoint only. Known values are: "None", "External", "Internal". Default value: "None". - :paramtype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + :paramtype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType :keyword api_version_constraint: Control Plane Apis version constraint for the API Management service. - :paramtype api_version_constraint: ~api_management_client.models.ApiVersionConstraint + :paramtype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint :keyword restore: Undelete Api Management Service if it was previously soft-deleted. If this flag is specified and set to True all other properties will be ignored. :paramtype restore: bool :keyword private_endpoint_connections: List of Private Endpoint Connections of this service. :paramtype private_endpoint_connections: - list[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] :keyword publisher_email: Required. Publisher email. :paramtype publisher_email: str :keyword publisher_name: Required. Publisher name. @@ -2700,11 +2704,11 @@ class ApiManagementServiceResource(ApimResource): :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: ~api_management_client.models.ApiManagementServiceSkuProperties + :vartype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties :ivar identity: Managed service identity of the Api Management service. - :vartype identity: ~api_management_client.models.ApiManagementServiceIdentity + :vartype identity: ~azure.mgmt.apimanagement.models.ApiManagementServiceIdentity :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~api_management_client.models.SystemData + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData :ivar location: Required. Resource location. :vartype location: str :ivar etag: ETag of the resource. @@ -2736,7 +2740,7 @@ class ApiManagementServiceResource(ApimResource): :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. :vartype developer_portal_url: str :ivar hostname_configurations: Custom hostname configuration of the API Management service. - :vartype hostname_configurations: list[~api_management_client.models.HostnameConfiguration] + :vartype hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. :vartype public_ip_addresses: list[str] @@ -2751,14 +2755,14 @@ class ApiManagementServiceResource(ApimResource): :ivar public_network_access: Whether or not public endpoint access is allowed for this API Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. - Possible values include: "Enabled", "Disabled". - :vartype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled", "Disabled". + :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :ivar virtual_network_configuration: Virtual network configuration of the API Management service. :vartype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :ivar additional_locations: Additional datacenter locations of the API Management service. - :vartype additional_locations: list[~api_management_client.models.AdditionalLocation] + :vartype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] :ivar custom_properties: Custom properties of the API Management service.
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting @@ -2789,7 +2793,7 @@ class ApiManagementServiceResource(ApimResource): :vartype custom_properties: dict[str, str] :ivar certificates: List of Certificates that need to be installed in the API Management service. Max supported certificates that can be installed is 10. - :vartype certificates: list[~api_management_client.models.CertificateConfiguration] + :vartype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] :ivar enable_client_certificate: Property only meant to be used for Consumption SKU Service. This enforces a client certificate to be presented on each request to the gateway. This also enables the ability to authenticate the certificate in the policy on the gateway. @@ -2801,21 +2805,21 @@ class ApiManagementServiceResource(ApimResource): configured in. None (Default Value) means the API Management service is not part of any Virtual Network, External means the API Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside - a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", + a Virtual Network having an Intranet Facing Endpoint only. Known values are: "None", "External", "Internal". Default value: "None". - :vartype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + :vartype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType :ivar api_version_constraint: Control Plane Apis version constraint for the API Management service. - :vartype api_version_constraint: ~api_management_client.models.ApiVersionConstraint + :vartype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint :ivar restore: Undelete Api Management Service if it was previously soft-deleted. If this flag is specified and set to True all other properties will be ignored. :vartype restore: bool :ivar private_endpoint_connections: List of Private Endpoint Connections of this service. :vartype private_endpoint_connections: - list[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] - :ivar platform_version: Compute Platform Version running the service in this location. Possible - values include: "undetermined", "stv1", "stv2", "mtv1". - :vartype platform_version: str or ~api_management_client.models.PlatformVersion + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :ivar platform_version: Compute Platform Version running the service in this location. Known + values are: "undetermined", "stv1", "stv2", "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. @@ -2891,36 +2895,36 @@ class ApiManagementServiceResource(ApimResource): def __init__( self, *, - sku: "ApiManagementServiceSkuProperties", + sku: "_models.ApiManagementServiceSkuProperties", location: str, publisher_email: str, publisher_name: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["ApiManagementServiceIdentity"] = None, + identity: Optional["_models.ApiManagementServiceIdentity"] = None, zones: Optional[List[str]] = None, notification_sender_email: Optional[str] = None, - hostname_configurations: Optional[List["HostnameConfiguration"]] = None, + hostname_configurations: Optional[List["_models.HostnameConfiguration"]] = None, public_ip_address_id: Optional[str] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - virtual_network_configuration: Optional["VirtualNetworkConfiguration"] = None, - additional_locations: Optional[List["AdditionalLocation"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + virtual_network_configuration: Optional["_models.VirtualNetworkConfiguration"] = None, + additional_locations: Optional[List["_models.AdditionalLocation"]] = None, custom_properties: Optional[Dict[str, str]] = None, - certificates: Optional[List["CertificateConfiguration"]] = None, + certificates: Optional[List["_models.CertificateConfiguration"]] = None, enable_client_certificate: Optional[bool] = False, disable_gateway: Optional[bool] = False, - virtual_network_type: Optional[Union[str, "VirtualNetworkType"]] = "None", - api_version_constraint: Optional["ApiVersionConstraint"] = None, + virtual_network_type: Optional[Union[str, "_models.VirtualNetworkType"]] = "None", + api_version_constraint: Optional["_models.ApiVersionConstraint"] = None, restore: Optional[bool] = False, - private_endpoint_connections: Optional[List["RemotePrivateEndpointConnectionWrapper"]] = None, + private_endpoint_connections: Optional[List["_models.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: ~api_management_client.models.ApiManagementServiceSkuProperties + :paramtype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties :keyword identity: Managed service identity of the Api Management service. - :paramtype identity: ~api_management_client.models.ApiManagementServiceIdentity + :paramtype identity: ~azure.mgmt.apimanagement.models.ApiManagementServiceIdentity :keyword location: Required. Resource location. :paramtype location: str :keyword zones: A list of availability zones denoting where the resource needs to come from. @@ -2928,7 +2932,8 @@ def __init__( :keyword notification_sender_email: Email address from which the notification will be sent. :paramtype notification_sender_email: str :keyword hostname_configurations: Custom hostname configuration of the API Management service. - :paramtype hostname_configurations: list[~api_management_client.models.HostnameConfiguration] + :paramtype hostname_configurations: + list[~azure.mgmt.apimanagement.models.HostnameConfiguration] :keyword public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with Virtual Network deployed service in the region. Supported only for Developer and Premium SKU being deployed in Virtual Network. @@ -2936,14 +2941,14 @@ def __init__( :keyword public_network_access: Whether or not public endpoint access is allowed for this API Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. - Possible values include: "Enabled", "Disabled". - :paramtype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled", "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :keyword virtual_network_configuration: Virtual network configuration of the API Management service. :paramtype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :keyword additional_locations: Additional datacenter locations of the API Management service. - :paramtype additional_locations: list[~api_management_client.models.AdditionalLocation] + :paramtype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] :keyword custom_properties: Custom properties of the API Management service.
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting @@ -2974,7 +2979,7 @@ def __init__( :paramtype custom_properties: dict[str, str] :keyword certificates: List of Certificates that need to be installed in the API Management service. Max supported certificates that can be installed is 10. - :paramtype certificates: list[~api_management_client.models.CertificateConfiguration] + :paramtype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] :keyword enable_client_certificate: Property only meant to be used for Consumption SKU Service. This enforces a client certificate to be presented on each request to the gateway. This also enables the ability to authenticate the certificate in the policy on the gateway. @@ -2986,18 +2991,18 @@ def __init__( configured in. None (Default Value) means the API Management service is not part of any Virtual Network, External means the API Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside - a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", + a Virtual Network having an Intranet Facing Endpoint only. Known values are: "None", "External", "Internal". Default value: "None". - :paramtype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + :paramtype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType :keyword api_version_constraint: Control Plane Apis version constraint for the API Management service. - :paramtype api_version_constraint: ~api_management_client.models.ApiVersionConstraint + :paramtype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint :keyword restore: Undelete Api Management Service if it was previously soft-deleted. If this flag is specified and set to True all other properties will be ignored. :paramtype restore: bool :keyword private_endpoint_connections: List of Private Endpoint Connections of this service. :paramtype private_endpoint_connections: - list[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] :keyword publisher_email: Required. Publisher email. :paramtype publisher_email: str :keyword publisher_name: Required. Publisher name. @@ -3045,9 +3050,9 @@ class ApiManagementServiceSkuProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of the Sku. Possible values include: "Developer", "Standard", - "Premium", "Basic", "Consumption", "Isolated". - :vartype name: str or ~api_management_client.models.SkuType + :ivar name: Required. Name of the Sku. Known values are: "Developer", "Standard", "Premium", + "Basic", "Consumption", "Isolated". + :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. :vartype capacity: int @@ -3066,14 +3071,14 @@ class ApiManagementServiceSkuProperties(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuType"], + name: Union[str, "_models.SkuType"], capacity: int, **kwargs ): """ - :keyword name: Required. Name of the Sku. Possible values include: "Developer", "Standard", - "Premium", "Basic", "Consumption", "Isolated". - :paramtype name: str or ~api_management_client.models.SkuType + :keyword name: Required. Name of the Sku. Known values are: "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 @@ -3097,9 +3102,9 @@ class ApiManagementServiceUpdateParameters(ApimResource): :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar sku: SKU properties of the API Management service. - :vartype sku: ~api_management_client.models.ApiManagementServiceSkuProperties + :vartype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties :ivar identity: Managed service identity of the Api Management service. - :vartype identity: ~api_management_client.models.ApiManagementServiceIdentity + :vartype identity: ~azure.mgmt.apimanagement.models.ApiManagementServiceIdentity :ivar etag: ETag of the resource. :vartype etag: str :ivar zones: A list of availability zones denoting where the resource needs to come from. @@ -3129,7 +3134,7 @@ class ApiManagementServiceUpdateParameters(ApimResource): :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. :vartype developer_portal_url: str :ivar hostname_configurations: Custom hostname configuration of the API Management service. - :vartype hostname_configurations: list[~api_management_client.models.HostnameConfiguration] + :vartype hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. :vartype public_ip_addresses: list[str] @@ -3144,14 +3149,14 @@ class ApiManagementServiceUpdateParameters(ApimResource): :ivar public_network_access: Whether or not public endpoint access is allowed for this API Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. - Possible values include: "Enabled", "Disabled". - :vartype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled", "Disabled". + :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :ivar virtual_network_configuration: Virtual network configuration of the API Management service. :vartype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :ivar additional_locations: Additional datacenter locations of the API Management service. - :vartype additional_locations: list[~api_management_client.models.AdditionalLocation] + :vartype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] :ivar custom_properties: Custom properties of the API Management service.
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting @@ -3182,7 +3187,7 @@ class ApiManagementServiceUpdateParameters(ApimResource): :vartype custom_properties: dict[str, str] :ivar certificates: List of Certificates that need to be installed in the API Management service. Max supported certificates that can be installed is 10. - :vartype certificates: list[~api_management_client.models.CertificateConfiguration] + :vartype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] :ivar enable_client_certificate: Property only meant to be used for Consumption SKU Service. This enforces a client certificate to be presented on each request to the gateway. This also enables the ability to authenticate the certificate in the policy on the gateway. @@ -3194,21 +3199,21 @@ class ApiManagementServiceUpdateParameters(ApimResource): configured in. None (Default Value) means the API Management service is not part of any Virtual Network, External means the API Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside - a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", + a Virtual Network having an Intranet Facing Endpoint only. Known values are: "None", "External", "Internal". Default value: "None". - :vartype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + :vartype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType :ivar api_version_constraint: Control Plane Apis version constraint for the API Management service. - :vartype api_version_constraint: ~api_management_client.models.ApiVersionConstraint + :vartype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint :ivar restore: Undelete Api Management Service if it was previously soft-deleted. If this flag is specified and set to True all other properties will be ignored. :vartype restore: bool :ivar private_endpoint_connections: List of Private Endpoint Connections of this service. :vartype private_endpoint_connections: - list[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] - :ivar platform_version: Compute Platform Version running the service in this location. Possible - values include: "undetermined", "stv1", "stv2", "mtv1". - :vartype platform_version: str or ~api_management_client.models.PlatformVersion + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :ivar platform_version: Compute Platform Version running the service in this location. Known + values are: "undetermined", "stv1", "stv2", "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. @@ -3280,23 +3285,23 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["ApiManagementServiceSkuProperties"] = None, - identity: Optional["ApiManagementServiceIdentity"] = None, + sku: Optional["_models.ApiManagementServiceSkuProperties"] = None, + identity: Optional["_models.ApiManagementServiceIdentity"] = None, zones: Optional[List[str]] = None, notification_sender_email: Optional[str] = None, - hostname_configurations: Optional[List["HostnameConfiguration"]] = None, + hostname_configurations: Optional[List["_models.HostnameConfiguration"]] = None, public_ip_address_id: Optional[str] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - virtual_network_configuration: Optional["VirtualNetworkConfiguration"] = None, - additional_locations: Optional[List["AdditionalLocation"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + virtual_network_configuration: Optional["_models.VirtualNetworkConfiguration"] = None, + additional_locations: Optional[List["_models.AdditionalLocation"]] = None, custom_properties: Optional[Dict[str, str]] = None, - certificates: Optional[List["CertificateConfiguration"]] = None, + certificates: Optional[List["_models.CertificateConfiguration"]] = None, enable_client_certificate: Optional[bool] = False, disable_gateway: Optional[bool] = False, - virtual_network_type: Optional[Union[str, "VirtualNetworkType"]] = "None", - api_version_constraint: Optional["ApiVersionConstraint"] = None, + virtual_network_type: Optional[Union[str, "_models.VirtualNetworkType"]] = "None", + api_version_constraint: Optional["_models.ApiVersionConstraint"] = None, restore: Optional[bool] = False, - private_endpoint_connections: Optional[List["RemotePrivateEndpointConnectionWrapper"]] = None, + private_endpoint_connections: Optional[List["_models.RemotePrivateEndpointConnectionWrapper"]] = None, publisher_email: Optional[str] = None, publisher_name: Optional[str] = None, **kwargs @@ -3305,15 +3310,16 @@ def __init__( :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] :keyword sku: SKU properties of the API Management service. - :paramtype sku: ~api_management_client.models.ApiManagementServiceSkuProperties + :paramtype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties :keyword identity: Managed service identity of the Api Management service. - :paramtype identity: ~api_management_client.models.ApiManagementServiceIdentity + :paramtype identity: ~azure.mgmt.apimanagement.models.ApiManagementServiceIdentity :keyword zones: A list of availability zones denoting where the resource needs to come from. :paramtype zones: list[str] :keyword notification_sender_email: Email address from which the notification will be sent. :paramtype notification_sender_email: str :keyword hostname_configurations: Custom hostname configuration of the API Management service. - :paramtype hostname_configurations: list[~api_management_client.models.HostnameConfiguration] + :paramtype hostname_configurations: + list[~azure.mgmt.apimanagement.models.HostnameConfiguration] :keyword public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with Virtual Network deployed service in the region. Supported only for Developer and Premium SKU being deployed in Virtual Network. @@ -3321,14 +3327,14 @@ def __init__( :keyword public_network_access: Whether or not public endpoint access is allowed for this API Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. - Possible values include: "Enabled", "Disabled". - :paramtype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled", "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :keyword virtual_network_configuration: Virtual network configuration of the API Management service. :paramtype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :keyword additional_locations: Additional datacenter locations of the API Management service. - :paramtype additional_locations: list[~api_management_client.models.AdditionalLocation] + :paramtype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] :keyword custom_properties: Custom properties of the API Management service.
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting @@ -3359,7 +3365,7 @@ def __init__( :paramtype custom_properties: dict[str, str] :keyword certificates: List of Certificates that need to be installed in the API Management service. Max supported certificates that can be installed is 10. - :paramtype certificates: list[~api_management_client.models.CertificateConfiguration] + :paramtype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] :keyword enable_client_certificate: Property only meant to be used for Consumption SKU Service. This enforces a client certificate to be presented on each request to the gateway. This also enables the ability to authenticate the certificate in the policy on the gateway. @@ -3371,18 +3377,18 @@ def __init__( configured in. None (Default Value) means the API Management service is not part of any Virtual Network, External means the API Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside - a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", + a Virtual Network having an Intranet Facing Endpoint only. Known values are: "None", "External", "Internal". Default value: "None". - :paramtype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + :paramtype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType :keyword api_version_constraint: Control Plane Apis version constraint for the API Management service. - :paramtype api_version_constraint: ~api_management_client.models.ApiVersionConstraint + :paramtype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint :keyword restore: Undelete Api Management Service if it was previously soft-deleted. If this flag is specified and set to True all other properties will be ignored. :paramtype restore: bool :keyword private_endpoint_connections: List of Private Endpoint Connections of this service. :paramtype private_endpoint_connections: - list[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] :keyword publisher_email: Publisher email. :paramtype publisher_email: str :keyword publisher_name: Publisher name. @@ -3453,7 +3459,7 @@ class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. :vartype developer_portal_url: str :ivar hostname_configurations: Custom hostname configuration of the API Management service. - :vartype hostname_configurations: list[~api_management_client.models.HostnameConfiguration] + :vartype hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. :vartype public_ip_addresses: list[str] @@ -3468,14 +3474,14 @@ class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): :ivar public_network_access: Whether or not public endpoint access is allowed for this API Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. - Possible values include: "Enabled", "Disabled". - :vartype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled", "Disabled". + :vartype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :ivar virtual_network_configuration: Virtual network configuration of the API Management service. :vartype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :ivar additional_locations: Additional datacenter locations of the API Management service. - :vartype additional_locations: list[~api_management_client.models.AdditionalLocation] + :vartype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] :ivar custom_properties: Custom properties of the API Management service.
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting @@ -3506,7 +3512,7 @@ class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): :vartype custom_properties: dict[str, str] :ivar certificates: List of Certificates that need to be installed in the API Management service. Max supported certificates that can be installed is 10. - :vartype certificates: list[~api_management_client.models.CertificateConfiguration] + :vartype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] :ivar enable_client_certificate: Property only meant to be used for Consumption SKU Service. This enforces a client certificate to be presented on each request to the gateway. This also enables the ability to authenticate the certificate in the policy on the gateway. @@ -3518,21 +3524,21 @@ class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): configured in. None (Default Value) means the API Management service is not part of any Virtual Network, External means the API Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside - a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", + a Virtual Network having an Intranet Facing Endpoint only. Known values are: "None", "External", "Internal". Default value: "None". - :vartype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + :vartype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType :ivar api_version_constraint: Control Plane Apis version constraint for the API Management service. - :vartype api_version_constraint: ~api_management_client.models.ApiVersionConstraint + :vartype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint :ivar restore: Undelete Api Management Service if it was previously soft-deleted. If this flag is specified and set to True all other properties will be ignored. :vartype restore: bool :ivar private_endpoint_connections: List of Private Endpoint Connections of this service. :vartype private_endpoint_connections: - list[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] - :ivar platform_version: Compute Platform Version running the service in this location. Possible - values include: "undetermined", "stv1", "stv2", "mtv1". - :vartype platform_version: str or ~api_management_client.models.PlatformVersion + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] + :ivar platform_version: Compute Platform Version running the service in this location. Known + values are: "undetermined", "stv1", "stv2", "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. @@ -3592,19 +3598,19 @@ def __init__( self, *, notification_sender_email: Optional[str] = None, - hostname_configurations: Optional[List["HostnameConfiguration"]] = None, + hostname_configurations: Optional[List["_models.HostnameConfiguration"]] = None, public_ip_address_id: Optional[str] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - virtual_network_configuration: Optional["VirtualNetworkConfiguration"] = None, - additional_locations: Optional[List["AdditionalLocation"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + virtual_network_configuration: Optional["_models.VirtualNetworkConfiguration"] = None, + additional_locations: Optional[List["_models.AdditionalLocation"]] = None, custom_properties: Optional[Dict[str, str]] = None, - certificates: Optional[List["CertificateConfiguration"]] = None, + certificates: Optional[List["_models.CertificateConfiguration"]] = None, enable_client_certificate: Optional[bool] = False, disable_gateway: Optional[bool] = False, - virtual_network_type: Optional[Union[str, "VirtualNetworkType"]] = "None", - api_version_constraint: Optional["ApiVersionConstraint"] = None, + virtual_network_type: Optional[Union[str, "_models.VirtualNetworkType"]] = "None", + api_version_constraint: Optional["_models.ApiVersionConstraint"] = None, restore: Optional[bool] = False, - private_endpoint_connections: Optional[List["RemotePrivateEndpointConnectionWrapper"]] = None, + private_endpoint_connections: Optional[List["_models.RemotePrivateEndpointConnectionWrapper"]] = None, publisher_email: Optional[str] = None, publisher_name: Optional[str] = None, **kwargs @@ -3613,7 +3619,8 @@ def __init__( :keyword notification_sender_email: Email address from which the notification will be sent. :paramtype notification_sender_email: str :keyword hostname_configurations: Custom hostname configuration of the API Management service. - :paramtype hostname_configurations: list[~api_management_client.models.HostnameConfiguration] + :paramtype hostname_configurations: + list[~azure.mgmt.apimanagement.models.HostnameConfiguration] :keyword public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with Virtual Network deployed service in the region. Supported only for Developer and Premium SKU being deployed in Virtual Network. @@ -3621,14 +3628,14 @@ def __init__( :keyword public_network_access: Whether or not public endpoint access is allowed for this API Management service. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'. - Possible values include: "Enabled", "Disabled". - :paramtype public_network_access: str or ~api_management_client.models.PublicNetworkAccess + Known values are: "Enabled", "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.apimanagement.models.PublicNetworkAccess :keyword virtual_network_configuration: Virtual network configuration of the API Management service. :paramtype virtual_network_configuration: - ~api_management_client.models.VirtualNetworkConfiguration + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration :keyword additional_locations: Additional datacenter locations of the API Management service. - :paramtype additional_locations: list[~api_management_client.models.AdditionalLocation] + :paramtype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] :keyword custom_properties: Custom properties of the API Management service.
Setting ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting @@ -3659,7 +3666,7 @@ def __init__( :paramtype custom_properties: dict[str, str] :keyword certificates: List of Certificates that need to be installed in the API Management service. Max supported certificates that can be installed is 10. - :paramtype certificates: list[~api_management_client.models.CertificateConfiguration] + :paramtype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] :keyword enable_client_certificate: Property only meant to be used for Consumption SKU Service. This enforces a client certificate to be presented on each request to the gateway. This also enables the ability to authenticate the certificate in the policy on the gateway. @@ -3671,18 +3678,18 @@ def __init__( configured in. None (Default Value) means the API Management service is not part of any Virtual Network, External means the API Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside - a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", + a Virtual Network having an Intranet Facing Endpoint only. Known values are: "None", "External", "Internal". Default value: "None". - :paramtype virtual_network_type: str or ~api_management_client.models.VirtualNetworkType + :paramtype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType :keyword api_version_constraint: Control Plane Apis version constraint for the API Management service. - :paramtype api_version_constraint: ~api_management_client.models.ApiVersionConstraint + :paramtype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint :keyword restore: Undelete Api Management Service if it was previously soft-deleted. If this flag is specified and set to True all other properties will be ignored. :paramtype restore: bool :keyword private_endpoint_connections: List of Private Endpoint Connections of this service. :paramtype private_endpoint_connections: - list[~api_management_client.models.RemotePrivateEndpointConnectionWrapper] + list[~azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper] :keyword publisher_email: Publisher email. :paramtype publisher_email: str :keyword publisher_name: Publisher name. @@ -3713,21 +3720,21 @@ class ApiManagementSku(msrest.serialization.Model): :ivar kind: The Kind of resources that are supported in this SKU. :vartype kind: str :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: ~api_management_client.models.ApiManagementSkuCapacity + :vartype capacity: ~azure.mgmt.apimanagement.models.ApiManagementSkuCapacity :ivar locations: The set of locations that the SKU is available. :vartype locations: list[str] :ivar location_info: A list of locations and availability zones in those locations where the SKU is available. - :vartype location_info: list[~api_management_client.models.ApiManagementSkuLocationInfo] + :vartype location_info: list[~azure.mgmt.apimanagement.models.ApiManagementSkuLocationInfo] :ivar api_versions: The api versions that support this SKU. :vartype api_versions: list[str] :ivar costs: Metadata for retrieving price info. - :vartype costs: list[~api_management_client.models.ApiManagementSkuCosts] + :vartype costs: list[~azure.mgmt.apimanagement.models.ApiManagementSkuCosts] :ivar capabilities: A name value pair to describe the capability. - :vartype capabilities: list[~api_management_client.models.ApiManagementSkuCapabilities] + :vartype capabilities: list[~azure.mgmt.apimanagement.models.ApiManagementSkuCapabilities] :ivar restrictions: The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. - :vartype restrictions: list[~api_management_client.models.ApiManagementSkuRestrictions] + :vartype restrictions: list[~azure.mgmt.apimanagement.models.ApiManagementSkuRestrictions] """ _validation = { @@ -3827,9 +3834,9 @@ class ApiManagementSkuCapacity(msrest.serialization.Model): :vartype maximum: int :ivar default: The default capacity. :vartype default: int - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "Manual", "None". - :vartype scale_type: str or ~api_management_client.models.ApiManagementSkuCapacityScaleType + :vartype scale_type: str or ~azure.mgmt.apimanagement.models.ApiManagementSkuCapacityScaleType """ _validation = { @@ -3906,7 +3913,7 @@ class ApiManagementSkuLocationInfo(msrest.serialization.Model): :ivar zones: List of availability zones where the SKU is supported. :vartype zones: list[str] :ivar zone_details: Details of capabilities available to a SKU in specific zones. - :vartype zone_details: list[~api_management_client.models.ApiManagementSkuZoneDetails] + :vartype zone_details: list[~azure.mgmt.apimanagement.models.ApiManagementSkuZoneDetails] """ _validation = { @@ -3970,17 +3977,17 @@ class ApiManagementSkuRestrictions(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar type: The type of restrictions. Possible values include: "Location", "Zone". - :vartype type: str or ~api_management_client.models.ApiManagementSkuRestrictionsType + :ivar type: The type of restrictions. Known values are: "Location", "Zone". + :vartype type: str or ~azure.mgmt.apimanagement.models.ApiManagementSkuRestrictionsType :ivar values: The value of restrictions. If the restriction type is set to location. This would be different locations where the SKU is restricted. :vartype values: list[str] :ivar restriction_info: The information about the restriction where the SKU cannot be used. - :vartype restriction_info: ~api_management_client.models.ApiManagementSkuRestrictionInfo - :ivar reason_code: The reason for restriction. Possible values include: "QuotaId", + :vartype restriction_info: ~azure.mgmt.apimanagement.models.ApiManagementSkuRestrictionInfo + :ivar reason_code: The reason for restriction. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or - ~api_management_client.models.ApiManagementSkuRestrictionsReasonCode + ~azure.mgmt.apimanagement.models.ApiManagementSkuRestrictionsReasonCode """ _validation = { @@ -4018,7 +4025,7 @@ class ApiManagementSkusResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar value: Required. The list of skus available for the subscription. - :vartype value: list[~api_management_client.models.ApiManagementSku] + :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 @@ -4037,12 +4044,12 @@ class ApiManagementSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["ApiManagementSku"], + value: List["_models.ApiManagementSku"], **kwargs ): """ :keyword value: Required. The list of skus available for the subscription. - :paramtype value: list[~api_management_client.models.ApiManagementSku] + :paramtype value: list[~azure.mgmt.apimanagement.models.ApiManagementSku] """ super(ApiManagementSkusResult, self).__init__(**kwargs) self.value = value @@ -4058,7 +4065,7 @@ class ApiManagementSkuZoneDetails(msrest.serialization.Model): :vartype name: list[str] :ivar capabilities: A list of capabilities that are available for the SKU in the specified list of zones. - :vartype capabilities: list[~api_management_client.models.ApiManagementSkuCapabilities] + :vartype capabilities: list[~azure.mgmt.apimanagement.models.ApiManagementSkuCapabilities] """ _validation = { @@ -4088,7 +4095,7 @@ class ApiReleaseCollection(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Page values. - :vartype value: list[~api_management_client.models.ApiReleaseContract] + :vartype value: list[~azure.mgmt.apimanagement.models.ApiReleaseContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -4190,7 +4197,7 @@ class ApiRevisionCollection(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Page values. - :vartype value: list[~api_management_client.models.ApiRevisionContract] + :vartype value: list[~azure.mgmt.apimanagement.models.ApiRevisionContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -4298,7 +4305,7 @@ class ApiRevisionInfoContract(msrest.serialization.Model): :ivar api_revision_description: Description of new API Revision. :vartype api_revision_description: str :ivar api_version_set: Version set details. - :vartype api_version_set: ~api_management_client.models.ApiVersionSetContractDetails + :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ _validation = { @@ -4319,7 +4326,7 @@ def __init__( source_api_id: Optional[str] = None, api_version_name: Optional[str] = None, api_revision_description: Optional[str] = None, - api_version_set: Optional["ApiVersionSetContractDetails"] = None, + api_version_set: Optional["_models.ApiVersionSetContractDetails"] = None, **kwargs ): """ @@ -4330,7 +4337,7 @@ def __init__( :keyword api_revision_description: Description of new API Revision. :paramtype api_revision_description: str :keyword api_version_set: Version set details. - :paramtype api_version_set: ~api_management_client.models.ApiVersionSetContractDetails + :paramtype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ super(ApiRevisionInfoContract, self).__init__(**kwargs) self.source_api_id = source_api_id @@ -4347,12 +4354,13 @@ class ApiTagResourceContractProperties(ApiEntityBaseContract): :ivar description: Description of the API. May include HTML formatting tags. :vartype description: str :ivar authentication_settings: Collection of authentication settings included into this API. - :vartype authentication_settings: ~api_management_client.models.AuthenticationSettingsContract + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :ivar subscription_key_parameter_names: Protocols over which API is made available. :vartype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "graphql". - :vartype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql". + :vartype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :ivar api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. :vartype api_revision: str @@ -4375,9 +4383,9 @@ class ApiTagResourceContractProperties(ApiEntityBaseContract): a URL. :vartype terms_of_service_url: str :ivar contact: Contact information for the API. - :vartype contact: ~api_management_client.models.ApiContactInformation + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :ivar license: License information for the API. - :vartype license: ~api_management_client.models.ApiLicenseInformation + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation :ivar id: API identifier in the form /apis/{apiId}. :vartype id: str :ivar name: API name. @@ -4389,7 +4397,7 @@ class ApiTagResourceContractProperties(ApiEntityBaseContract): the service instance creation to form a public URL for this API. :vartype path: str :ivar protocols: Describes on which protocols the operations in this API can be invoked. - :vartype protocols: list[str or ~api_management_client.models.Protocol] + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] """ _validation = { @@ -4430,9 +4438,9 @@ def __init__( self, *, description: Optional[str] = None, - authentication_settings: Optional["AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "ApiType"]] = None, + authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, + subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, + api_type: Optional[Union[str, "_models.ApiType"]] = None, api_revision: Optional[str] = None, api_version: Optional[str] = None, is_current: Optional[bool] = None, @@ -4441,13 +4449,13 @@ def __init__( api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, terms_of_service_url: Optional[str] = None, - contact: Optional["ApiContactInformation"] = None, - license: Optional["ApiLicenseInformation"] = None, + contact: Optional["_models.ApiContactInformation"] = None, + license: Optional["_models.ApiLicenseInformation"] = None, id: Optional[str] = None, name: Optional[str] = None, service_url: Optional[str] = None, path: Optional[str] = None, - protocols: Optional[List[Union[str, "Protocol"]]] = None, + protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, **kwargs ): """ @@ -4455,13 +4463,12 @@ def __init__( :paramtype description: str :keyword authentication_settings: Collection of authentication settings included into this API. :paramtype authentication_settings: - ~api_management_client.models.AuthenticationSettingsContract + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", - "graphql". - :paramtype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql". + :paramtype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :keyword api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. :paramtype api_revision: str @@ -4482,9 +4489,9 @@ def __init__( of a URL. :paramtype terms_of_service_url: str :keyword contact: Contact information for the API. - :paramtype contact: ~api_management_client.models.ApiContactInformation + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :keyword license: License information for the API. - :paramtype license: ~api_management_client.models.ApiLicenseInformation + :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation :keyword id: API identifier in the form /apis/{apiId}. :paramtype id: str :keyword name: API name. @@ -4496,7 +4503,7 @@ def __init__( during the service instance creation to form a public URL for this API. :paramtype path: str :keyword protocols: Describes on which protocols the operations in this API can be invoked. - :paramtype protocols: list[str or ~api_management_client.models.Protocol] + :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] """ super(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 @@ -4514,12 +4521,13 @@ class ApiUpdateContract(msrest.serialization.Model): :ivar description: Description of the API. May include HTML formatting tags. :vartype description: str :ivar authentication_settings: Collection of authentication settings included into this API. - :vartype authentication_settings: ~api_management_client.models.AuthenticationSettingsContract + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :ivar subscription_key_parameter_names: Protocols over which API is made available. :vartype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :ivar api_type: Type of API. Possible values include: "http", "soap", "websocket", "graphql". - :vartype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :ivar api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql". + :vartype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :ivar api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. :vartype api_revision: str @@ -4542,9 +4550,9 @@ class ApiUpdateContract(msrest.serialization.Model): a URL. :vartype terms_of_service_url: str :ivar contact: Contact information for the API. - :vartype contact: ~api_management_client.models.ApiContactInformation + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :ivar license: License information for the API. - :vartype license: ~api_management_client.models.ApiLicenseInformation + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation :ivar display_name: API name. :vartype display_name: str :ivar service_url: Absolute URL of the backend service implementing this API. @@ -4554,7 +4562,7 @@ class ApiUpdateContract(msrest.serialization.Model): the service instance creation to form a public URL for this API. :vartype path: str :ivar protocols: Describes on which protocols the operations in this API can be invoked. - :vartype protocols: list[str or ~api_management_client.models.Protocol] + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] """ _validation = { @@ -4594,9 +4602,9 @@ def __init__( self, *, description: Optional[str] = None, - authentication_settings: Optional["AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "ApiType"]] = None, + authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, + subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, + api_type: Optional[Union[str, "_models.ApiType"]] = None, api_revision: Optional[str] = None, api_version: Optional[str] = None, is_current: Optional[bool] = None, @@ -4605,12 +4613,12 @@ def __init__( api_version_set_id: Optional[str] = None, subscription_required: Optional[bool] = None, terms_of_service_url: Optional[str] = None, - contact: Optional["ApiContactInformation"] = None, - license: Optional["ApiLicenseInformation"] = None, + contact: Optional["_models.ApiContactInformation"] = None, + license: Optional["_models.ApiLicenseInformation"] = None, display_name: Optional[str] = None, service_url: Optional[str] = None, path: Optional[str] = None, - protocols: Optional[List[Union[str, "Protocol"]]] = None, + protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, **kwargs ): """ @@ -4618,13 +4626,12 @@ def __init__( :paramtype description: str :keyword authentication_settings: Collection of authentication settings included into this API. :paramtype authentication_settings: - ~api_management_client.models.AuthenticationSettingsContract + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract :keyword subscription_key_parameter_names: Protocols over which API is made available. :paramtype subscription_key_parameter_names: - ~api_management_client.models.SubscriptionKeyParameterNamesContract - :keyword api_type: Type of API. Possible values include: "http", "soap", "websocket", - "graphql". - :paramtype api_type: str or ~api_management_client.models.ApiType + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :keyword api_type: Type of API. Known values are: "http", "soap", "websocket", "graphql". + :paramtype api_type: str or ~azure.mgmt.apimanagement.models.ApiType :keyword api_revision: Describes the revision of the API. If no value is provided, default revision 1 is created. :paramtype api_revision: str @@ -4645,9 +4652,9 @@ def __init__( of a URL. :paramtype terms_of_service_url: str :keyword contact: Contact information for the API. - :paramtype contact: ~api_management_client.models.ApiContactInformation + :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation :keyword license: License information for the API. - :paramtype license: ~api_management_client.models.ApiLicenseInformation + :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation :keyword display_name: API name. :paramtype display_name: str :keyword service_url: Absolute URL of the backend service implementing this API. @@ -4657,7 +4664,7 @@ def __init__( during the service instance creation to form a public URL for this API. :paramtype path: str :keyword protocols: Describes on which protocols the operations in this API can be invoked. - :paramtype protocols: list[str or ~api_management_client.models.Protocol] + :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] """ super(ApiUpdateContract, self).__init__(**kwargs) self.description = description @@ -4712,7 +4719,7 @@ class ApiVersionSetCollection(msrest.serialization.Model): """Paged API Version Set list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.ApiVersionSetContract] + :vartype value: list[~azure.mgmt.apimanagement.models.ApiVersionSetContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -4728,14 +4735,14 @@ class ApiVersionSetCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ApiVersionSetContract"]] = None, + value: Optional[List["_models.ApiVersionSetContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.ApiVersionSetContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.ApiVersionSetContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -4771,8 +4778,8 @@ class ApiVersionSetContract(Resource): :ivar display_name: Name of API Version Set. :vartype display_name: str :ivar versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Possible values include: "Segment", "Query", "Header". - :vartype versioning_scheme: str or ~api_management_client.models.VersioningScheme + located in a HTTP request. Known values are: "Segment", "Query", "Header". + :vartype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme """ _validation = { @@ -4802,7 +4809,7 @@ def __init__( version_query_name: Optional[str] = None, version_header_name: Optional[str] = None, display_name: Optional[str] = None, - versioning_scheme: Optional[Union[str, "VersioningScheme"]] = None, + versioning_scheme: Optional[Union[str, "_models.VersioningScheme"]] = None, **kwargs ): """ @@ -4817,8 +4824,8 @@ def __init__( :keyword display_name: Name of API Version Set. :paramtype display_name: str :keyword versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Possible values include: "Segment", "Query", "Header". - :paramtype versioning_scheme: str or ~api_management_client.models.VersioningScheme + located in a HTTP request. Known values are: "Segment", "Query", "Header". + :paramtype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme """ super(ApiVersionSetContract, self).__init__(**kwargs) self.description = description @@ -4838,9 +4845,9 @@ class ApiVersionSetContractDetails(msrest.serialization.Model): :ivar description: Description of API Version Set. :vartype description: str :ivar versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Possible values include: "Segment", "Query", "Header". + located in a HTTP request. Known values are: "Segment", "Query", "Header". :vartype versioning_scheme: str or - ~api_management_client.models.ApiVersionSetContractDetailsVersioningScheme + ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetailsVersioningScheme :ivar version_query_name: Name of query parameter that indicates the API Version if versioningScheme is set to ``query``. :vartype version_query_name: str @@ -4864,7 +4871,7 @@ def __init__( id: Optional[str] = None, name: Optional[str] = None, description: Optional[str] = None, - versioning_scheme: Optional[Union[str, "ApiVersionSetContractDetailsVersioningScheme"]] = None, + versioning_scheme: Optional[Union[str, "_models.ApiVersionSetContractDetailsVersioningScheme"]] = None, version_query_name: Optional[str] = None, version_header_name: Optional[str] = None, **kwargs @@ -4878,9 +4885,9 @@ def __init__( :keyword description: Description of API Version Set. :paramtype description: str :keyword versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Possible values include: "Segment", "Query", "Header". + located in a HTTP request. Known values are: "Segment", "Query", "Header". :paramtype versioning_scheme: str or - ~api_management_client.models.ApiVersionSetContractDetailsVersioningScheme + ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetailsVersioningScheme :keyword version_query_name: Name of query parameter that indicates the API Version if versioningScheme is set to ``query``. :paramtype version_query_name: str @@ -4961,8 +4968,8 @@ class ApiVersionSetContractProperties(ApiVersionSetEntityBase): :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". - :vartype versioning_scheme: str or ~api_management_client.models.VersioningScheme + will be located in a HTTP request. Known values are: "Segment", "Query", "Header". + :vartype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme """ _validation = { @@ -4984,7 +4991,7 @@ def __init__( self, *, display_name: str, - versioning_scheme: Union[str, "VersioningScheme"], + versioning_scheme: Union[str, "_models.VersioningScheme"], description: Optional[str] = None, version_query_name: Optional[str] = None, version_header_name: Optional[str] = None, @@ -5002,8 +5009,8 @@ def __init__( :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 ~api_management_client.models.VersioningScheme + will be located in a HTTP request. Known values are: "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 @@ -5024,8 +5031,8 @@ class ApiVersionSetUpdateParameters(msrest.serialization.Model): :ivar display_name: Name of API Version Set. :vartype display_name: str :ivar versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Possible values include: "Segment", "Query", "Header". - :vartype versioning_scheme: str or ~api_management_client.models.VersioningScheme + located in a HTTP request. Known values are: "Segment", "Query", "Header". + :vartype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme """ _validation = { @@ -5049,7 +5056,7 @@ def __init__( version_query_name: Optional[str] = None, version_header_name: Optional[str] = None, display_name: Optional[str] = None, - versioning_scheme: Optional[Union[str, "VersioningScheme"]] = None, + versioning_scheme: Optional[Union[str, "_models.VersioningScheme"]] = None, **kwargs ): """ @@ -5064,8 +5071,8 @@ def __init__( :keyword display_name: Name of API Version Set. :paramtype display_name: str :keyword versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Possible values include: "Segment", "Query", "Header". - :paramtype versioning_scheme: str or ~api_management_client.models.VersioningScheme + located in a HTTP request. Known values are: "Segment", "Query", "Header". + :paramtype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme """ super(ApiVersionSetUpdateParameters, self).__init__(**kwargs) self.description = description @@ -5089,8 +5096,8 @@ class ApiVersionSetUpdateParametersProperties(ApiVersionSetEntityBase): :ivar display_name: Name of API Version Set. :vartype display_name: str :ivar versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Possible values include: "Segment", "Query", "Header". - :vartype versioning_scheme: str or ~api_management_client.models.VersioningScheme + located in a HTTP request. Known values are: "Segment", "Query", "Header". + :vartype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme """ _validation = { @@ -5114,7 +5121,7 @@ def __init__( version_query_name: Optional[str] = None, version_header_name: Optional[str] = None, display_name: Optional[str] = None, - versioning_scheme: Optional[Union[str, "VersioningScheme"]] = None, + versioning_scheme: Optional[Union[str, "_models.VersioningScheme"]] = None, **kwargs ): """ @@ -5129,8 +5136,8 @@ def __init__( :keyword display_name: Name of API Version Set. :paramtype display_name: str :keyword versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Possible values include: "Segment", "Query", "Header". - :paramtype versioning_scheme: str or ~api_management_client.models.VersioningScheme + located in a HTTP request. Known values are: "Segment", "Query", "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 @@ -5214,39 +5221,497 @@ class AuthenticationSettingsContract(msrest.serialization.Model): """API Authentication Settings. :ivar o_auth2: OAuth2 Authentication settings. - :vartype o_auth2: ~api_management_client.models.OAuth2AuthenticationSettingsContract + :vartype o_auth2: ~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract :ivar openid: OpenID Connect Authentication Settings. - :vartype openid: ~api_management_client.models.OpenIdAuthenticationSettingsContract + :vartype openid: ~azure.mgmt.apimanagement.models.OpenIdAuthenticationSettingsContract + :ivar o_auth2_authentication_settings: Collection of OAuth2 authentication settings included + into this API. + :vartype o_auth2_authentication_settings: + list[~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract] """ _attribute_map = { 'o_auth2': {'key': 'oAuth2', 'type': 'OAuth2AuthenticationSettingsContract'}, 'openid': {'key': 'openid', 'type': 'OpenIdAuthenticationSettingsContract'}, + 'o_auth2_authentication_settings': {'key': 'oAuth2AuthenticationSettings', 'type': '[OAuth2AuthenticationSettingsContract]'}, } def __init__( self, *, - o_auth2: Optional["OAuth2AuthenticationSettingsContract"] = None, - openid: Optional["OpenIdAuthenticationSettingsContract"] = None, + o_auth2: Optional["_models.OAuth2AuthenticationSettingsContract"] = None, + openid: Optional["_models.OpenIdAuthenticationSettingsContract"] = None, + o_auth2_authentication_settings: Optional[List["_models.OAuth2AuthenticationSettingsContract"]] = None, **kwargs ): """ :keyword o_auth2: OAuth2 Authentication settings. - :paramtype o_auth2: ~api_management_client.models.OAuth2AuthenticationSettingsContract + :paramtype o_auth2: ~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract :keyword openid: OpenID Connect Authentication Settings. - :paramtype openid: ~api_management_client.models.OpenIdAuthenticationSettingsContract + :paramtype openid: ~azure.mgmt.apimanagement.models.OpenIdAuthenticationSettingsContract + :keyword o_auth2_authentication_settings: Collection of OAuth2 authentication settings included + into this API. + :paramtype o_auth2_authentication_settings: + list[~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract] """ super(AuthenticationSettingsContract, self).__init__(**kwargs) self.o_auth2 = o_auth2 self.openid = openid + self.o_auth2_authentication_settings = o_auth2_authentication_settings + + +class AuthorizationAccessPolicyCollection(msrest.serialization.Model): + """Paged Authorization Access Policy list representation. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[AuthorizationAccessPolicyContract]'}, + 'count': {'key': 'count', 'type': 'long'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.AuthorizationAccessPolicyContract"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract] + :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(AuthorizationAccessPolicyCollection, self).__init__(**kwargs) + self.value = value + self.count = count + self.next_link = next_link + + +class AuthorizationAccessPolicyContract(Resource): + """Authorization access policy contract. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 tenant_id: The Tenant Id. + :vartype tenant_id: str + :ivar object_id: The Object Id. + :vartype object_id: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, + 'object_id': {'key': 'properties.objectId', 'type': 'str'}, + } + + def __init__( + self, + *, + tenant_id: Optional[str] = None, + object_id: Optional[str] = None, + **kwargs + ): + """ + :keyword tenant_id: The Tenant Id. + :paramtype tenant_id: str + :keyword object_id: The Object Id. + :paramtype object_id: str + """ + super(AuthorizationAccessPolicyContract, self).__init__(**kwargs) + self.tenant_id = tenant_id + self.object_id = object_id + + +class AuthorizationCollection(msrest.serialization.Model): + """Paged Authorization list representation. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.AuthorizationContract] + :ivar count: Total record count number across all pages. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[AuthorizationContract]'}, + 'count': {'key': 'count', 'type': 'long'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.AuthorizationContract"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.AuthorizationContract] + :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(AuthorizationCollection, self).__init__(**kwargs) + self.value = value + self.count = count + self.next_link = next_link + + +class AuthorizationContract(Resource): + """Authorization contract. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar authorization_type: Authorization type options. Known values are: "OAuth2". + :vartype authorization_type: str or ~azure.mgmt.apimanagement.models.AuthorizationType + :ivar o_auth2_grant_type: OAuth2 grant type options. Known values are: "AuthorizationCode", + "ClientCredentials". + :vartype o_auth2_grant_type: str or ~azure.mgmt.apimanagement.models.OAuth2GrantType + :ivar parameters: Authorization parameters. + :vartype parameters: dict[str, str] + :ivar error: Authorization error details. + :vartype error: ~azure.mgmt.apimanagement.models.AuthorizationError + :ivar status: Status of the Authorization. + :vartype status: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'authorization_type': {'key': 'properties.authorizationType', 'type': 'str'}, + 'o_auth2_grant_type': {'key': 'properties.oauth2grantType', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': '{str}'}, + 'error': {'key': 'properties.error', 'type': 'AuthorizationError'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + } + + def __init__( + self, + *, + authorization_type: Optional[Union[str, "_models.AuthorizationType"]] = None, + o_auth2_grant_type: Optional[Union[str, "_models.OAuth2GrantType"]] = None, + parameters: Optional[Dict[str, str]] = None, + error: Optional["_models.AuthorizationError"] = None, + status: Optional[str] = None, + **kwargs + ): + """ + :keyword authorization_type: Authorization type options. Known values are: "OAuth2". + :paramtype authorization_type: str or ~azure.mgmt.apimanagement.models.AuthorizationType + :keyword o_auth2_grant_type: OAuth2 grant type options. Known values are: "AuthorizationCode", + "ClientCredentials". + :paramtype o_auth2_grant_type: str or ~azure.mgmt.apimanagement.models.OAuth2GrantType + :keyword parameters: Authorization parameters. + :paramtype parameters: dict[str, str] + :keyword error: Authorization error details. + :paramtype error: ~azure.mgmt.apimanagement.models.AuthorizationError + :keyword status: Status of the Authorization. + :paramtype status: str + """ + super(AuthorizationContract, self).__init__(**kwargs) + self.authorization_type = authorization_type + self.o_auth2_grant_type = o_auth2_grant_type + self.parameters = parameters + self.error = error + self.status = status + + +class AuthorizationError(msrest.serialization.Model): + """Authorization error details. + + :ivar code: Error code. + :vartype code: str + :ivar message: Error message. + :vartype message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message. + :paramtype message: str + """ + super(AuthorizationError, self).__init__(**kwargs) + self.code = code + self.message = message + + +class AuthorizationLoginRequestContract(msrest.serialization.Model): + """Authorization login request contract. + + :ivar post_login_redirect_url: The post redirect url after login is completed. + :vartype post_login_redirect_url: str + """ + + _attribute_map = { + 'post_login_redirect_url': {'key': 'postLoginRedirectUrl', 'type': 'str'}, + } + + def __init__( + self, + *, + post_login_redirect_url: Optional[str] = None, + **kwargs + ): + """ + :keyword post_login_redirect_url: The post redirect url after login is completed. + :paramtype post_login_redirect_url: str + """ + super(AuthorizationLoginRequestContract, self).__init__(**kwargs) + self.post_login_redirect_url = post_login_redirect_url + + +class AuthorizationLoginResponseContract(msrest.serialization.Model): + """Authorization login response contract. + + :ivar login_link: The login link. + :vartype login_link: str + """ + + _attribute_map = { + 'login_link': {'key': 'loginLink', 'type': 'str'}, + } + + def __init__( + self, + *, + login_link: Optional[str] = None, + **kwargs + ): + """ + :keyword login_link: The login link. + :paramtype login_link: str + """ + super(AuthorizationLoginResponseContract, self).__init__(**kwargs) + self.login_link = login_link + + +class AuthorizationProviderCollection(msrest.serialization.Model): + """Paged Authorization Provider list representation. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.AuthorizationProviderContract] + :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 = { + 'value': {'key': 'value', 'type': '[AuthorizationProviderContract]'}, + 'count': {'key': 'count', 'type': 'long'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.AuthorizationProviderContract"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Page values. + :paramtype value: list[~azure.mgmt.apimanagement.models.AuthorizationProviderContract] + :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(AuthorizationProviderCollection, self).__init__(**kwargs) + self.value = value + self.count = count + self.next_link = next_link + + +class AuthorizationProviderContract(Resource): + """Authorization Provider contract. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar display_name: Authorization Provider name. Must be 1 to 300 characters long. + :vartype display_name: str + :ivar identity_provider: Identity provider name. Must be 1 to 300 characters long. + :vartype identity_provider: str + :ivar oauth2: OAuth2 settings. + :vartype oauth2: ~azure.mgmt.apimanagement.models.AuthorizationProviderOAuth2Settings + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'display_name': {'max_length': 300, 'min_length': 1}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'identity_provider': {'key': 'properties.identityProvider', 'type': 'str'}, + 'oauth2': {'key': 'properties.oauth2', 'type': 'AuthorizationProviderOAuth2Settings'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + identity_provider: Optional[str] = None, + oauth2: Optional["_models.AuthorizationProviderOAuth2Settings"] = None, + **kwargs + ): + """ + :keyword display_name: Authorization Provider name. Must be 1 to 300 characters long. + :paramtype display_name: str + :keyword identity_provider: Identity provider name. Must be 1 to 300 characters long. + :paramtype identity_provider: str + :keyword oauth2: OAuth2 settings. + :paramtype oauth2: ~azure.mgmt.apimanagement.models.AuthorizationProviderOAuth2Settings + """ + super(AuthorizationProviderContract, self).__init__(**kwargs) + self.display_name = display_name + self.identity_provider = identity_provider + self.oauth2 = oauth2 + + +class AuthorizationProviderOAuth2GrantTypes(msrest.serialization.Model): + """Authorization Provider oauth2 grant types settings. + + :ivar authorization_code: OAuth2 authorization code grant parameters. + :vartype authorization_code: dict[str, str] + :ivar client_credentials: OAuth2 client credential grant parameters. + :vartype client_credentials: dict[str, str] + """ + + _attribute_map = { + 'authorization_code': {'key': 'authorizationCode', 'type': '{str}'}, + 'client_credentials': {'key': 'clientCredentials', 'type': '{str}'}, + } + + def __init__( + self, + *, + authorization_code: Optional[Dict[str, str]] = None, + client_credentials: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword authorization_code: OAuth2 authorization code grant parameters. + :paramtype authorization_code: dict[str, str] + :keyword client_credentials: OAuth2 client credential grant parameters. + :paramtype client_credentials: dict[str, str] + """ + super(AuthorizationProviderOAuth2GrantTypes, self).__init__(**kwargs) + self.authorization_code = authorization_code + self.client_credentials = client_credentials + + +class AuthorizationProviderOAuth2Settings(msrest.serialization.Model): + """OAuth2 settings details. + + :ivar redirect_url: Redirect url to be set in the OAuth application. + :vartype redirect_url: str + :ivar grant_types: OAuth2 settings. + :vartype grant_types: ~azure.mgmt.apimanagement.models.AuthorizationProviderOAuth2GrantTypes + """ + + _attribute_map = { + 'redirect_url': {'key': 'redirectUrl', 'type': 'str'}, + 'grant_types': {'key': 'grantTypes', 'type': 'AuthorizationProviderOAuth2GrantTypes'}, + } + + def __init__( + self, + *, + redirect_url: Optional[str] = None, + grant_types: Optional["_models.AuthorizationProviderOAuth2GrantTypes"] = None, + **kwargs + ): + """ + :keyword redirect_url: Redirect url to be set in the OAuth application. + :paramtype redirect_url: str + :keyword grant_types: OAuth2 settings. + :paramtype grant_types: ~azure.mgmt.apimanagement.models.AuthorizationProviderOAuth2GrantTypes + """ + super(AuthorizationProviderOAuth2Settings, self).__init__(**kwargs) + self.redirect_url = redirect_url + self.grant_types = grant_types class AuthorizationServerCollection(msrest.serialization.Model): """Paged OAuth2 Authorization Servers list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.AuthorizationServerContract] + :vartype value: list[~azure.mgmt.apimanagement.models.AuthorizationServerContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -5262,14 +5727,14 @@ class AuthorizationServerCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["AuthorizationServerContract"]] = None, + value: Optional[List["_models.AuthorizationServerContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.AuthorizationServerContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.AuthorizationServerContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -5298,17 +5763,19 @@ class AuthorizationServerContract(Resource): :vartype description: str :ivar authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be always present. POST is optional. - :vartype authorization_methods: list[str or ~api_management_client.models.AuthorizationMethod] + :vartype authorization_methods: list[str or + ~azure.mgmt.apimanagement.models.AuthorizationMethod] :ivar client_authentication_method: Method of authentication supported by the token endpoint of this authorization server. Possible values are Basic and/or Body. When Body is specified, client credentials and other parameters are passed within the request body in the application/x-www-form-urlencoded format. :vartype client_authentication_method: list[str or - ~api_management_client.models.ClientAuthenticationMethod] + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] :ivar token_body_parameters: Additional parameters required by the token endpoint of this authorization server represented as an array of JSON objects with name and value string properties, i.e. {"name" : "name value", "value": "a value"}. - :vartype token_body_parameters: list[~api_management_client.models.TokenBodyParameterContract] + :vartype token_body_parameters: + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] :ivar token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :vartype token_endpoint: str :ivar support_state: If true, authorization server will include state parameter from the @@ -5322,7 +5789,7 @@ class AuthorizationServerContract(Resource): :ivar bearer_token_sending_methods: Specifies the mechanism by which access token is passed to the API. :vartype bearer_token_sending_methods: list[str or - ~api_management_client.models.BearerTokenSendingMethod] + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] :ivar resource_owner_username: Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. :vartype resource_owner_username: str @@ -5331,6 +5798,12 @@ class AuthorizationServerContract(Resource): :vartype resource_owner_password: str :ivar display_name: User-friendly authorization server name. :vartype display_name: str + :ivar use_in_test_console: If true, the authorization server may be used in the developer + portal test console. True by default if no value is provided. + :vartype use_in_test_console: bool + :ivar use_in_api_documentation: If true, the authorization server will be used in the API + documentation in the developer portal. False by default if no value is provided. + :vartype use_in_api_documentation: bool :ivar client_registration_endpoint: Optional reference to a page where client or app registration for this authorization server is performed. Contains absolute URL to entity being referenced. @@ -5340,7 +5813,7 @@ class AuthorizationServerContract(Resource): :vartype authorization_endpoint: str :ivar grant_types: Form of an authorization grant, which the client uses to request the access token. - :vartype grant_types: list[str or ~api_management_client.models.GrantType] + :vartype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] :ivar client_id: Client or app id registered with this authorization server. :vartype client_id: str :ivar client_secret: Client or app secret registered with this authorization server. This @@ -5371,6 +5844,8 @@ class AuthorizationServerContract(Resource): 'resource_owner_username': {'key': 'properties.resourceOwnerUsername', 'type': 'str'}, 'resource_owner_password': {'key': 'properties.resourceOwnerPassword', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'use_in_test_console': {'key': 'properties.useInTestConsole', 'type': 'bool'}, + 'use_in_api_documentation': {'key': 'properties.useInApiDocumentation', 'type': 'bool'}, 'client_registration_endpoint': {'key': 'properties.clientRegistrationEndpoint', 'type': 'str'}, 'authorization_endpoint': {'key': 'properties.authorizationEndpoint', 'type': 'str'}, 'grant_types': {'key': 'properties.grantTypes', 'type': '[str]'}, @@ -5382,19 +5857,21 @@ def __init__( self, *, description: Optional[str] = None, - authorization_methods: Optional[List[Union[str, "AuthorizationMethod"]]] = None, - client_authentication_method: Optional[List[Union[str, "ClientAuthenticationMethod"]]] = None, - token_body_parameters: Optional[List["TokenBodyParameterContract"]] = None, + authorization_methods: Optional[List[Union[str, "_models.AuthorizationMethod"]]] = None, + client_authentication_method: Optional[List[Union[str, "_models.ClientAuthenticationMethod"]]] = None, + token_body_parameters: Optional[List["_models.TokenBodyParameterContract"]] = None, token_endpoint: Optional[str] = None, support_state: Optional[bool] = None, default_scope: Optional[str] = None, - bearer_token_sending_methods: Optional[List[Union[str, "BearerTokenSendingMethod"]]] = None, + bearer_token_sending_methods: Optional[List[Union[str, "_models.BearerTokenSendingMethod"]]] = None, resource_owner_username: Optional[str] = None, resource_owner_password: Optional[str] = None, display_name: Optional[str] = None, + use_in_test_console: Optional[bool] = None, + use_in_api_documentation: Optional[bool] = None, client_registration_endpoint: Optional[str] = None, authorization_endpoint: Optional[str] = None, - grant_types: Optional[List[Union[str, "GrantType"]]] = None, + grant_types: Optional[List[Union[str, "_models.GrantType"]]] = None, client_id: Optional[str] = None, client_secret: Optional[str] = None, **kwargs @@ -5406,18 +5883,18 @@ def __init__( :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be always present. POST is optional. :paramtype authorization_methods: list[str or - ~api_management_client.models.AuthorizationMethod] + ~azure.mgmt.apimanagement.models.AuthorizationMethod] :keyword client_authentication_method: Method of authentication supported by the token endpoint of this authorization server. Possible values are Basic and/or Body. When Body is specified, client credentials and other parameters are passed within the request body in the application/x-www-form-urlencoded format. :paramtype client_authentication_method: list[str or - ~api_management_client.models.ClientAuthenticationMethod] + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] :keyword token_body_parameters: Additional parameters required by the token endpoint of this authorization server represented as an array of JSON objects with name and value string properties, i.e. {"name" : "name value", "value": "a value"}. :paramtype token_body_parameters: - list[~api_management_client.models.TokenBodyParameterContract] + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :paramtype token_endpoint: str @@ -5432,7 +5909,7 @@ def __init__( :keyword bearer_token_sending_methods: Specifies the mechanism by which access token is passed to the API. :paramtype bearer_token_sending_methods: list[str or - ~api_management_client.models.BearerTokenSendingMethod] + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] :keyword resource_owner_username: Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. :paramtype resource_owner_username: str @@ -5441,6 +5918,12 @@ def __init__( :paramtype resource_owner_password: str :keyword display_name: User-friendly authorization server name. :paramtype display_name: str + :keyword use_in_test_console: If true, the authorization server may be used in the developer + portal test console. True by default if no value is provided. + :paramtype use_in_test_console: bool + :keyword use_in_api_documentation: If true, the authorization server will be used in the API + documentation in the developer portal. False by default if no value is provided. + :paramtype use_in_api_documentation: bool :keyword client_registration_endpoint: Optional reference to a page where client or app registration for this authorization server is performed. Contains absolute URL to entity being referenced. @@ -5450,7 +5933,7 @@ def __init__( :paramtype authorization_endpoint: str :keyword grant_types: Form of an authorization grant, which the client uses to request the access token. - :paramtype grant_types: list[str or ~api_management_client.models.GrantType] + :paramtype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] :keyword client_id: Client or app id registered with this authorization server. :paramtype client_id: str :keyword client_secret: Client or app secret registered with this authorization server. This @@ -5470,6 +5953,8 @@ def __init__( self.resource_owner_username = resource_owner_username self.resource_owner_password = resource_owner_password self.display_name = display_name + self.use_in_test_console = use_in_test_console + self.use_in_api_documentation = use_in_api_documentation self.client_registration_endpoint = client_registration_endpoint self.authorization_endpoint = authorization_endpoint self.grant_types = grant_types @@ -5484,17 +5969,19 @@ class AuthorizationServerContractBaseProperties(msrest.serialization.Model): :vartype description: str :ivar authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be always present. POST is optional. - :vartype authorization_methods: list[str or ~api_management_client.models.AuthorizationMethod] + :vartype authorization_methods: list[str or + ~azure.mgmt.apimanagement.models.AuthorizationMethod] :ivar client_authentication_method: Method of authentication supported by the token endpoint of this authorization server. Possible values are Basic and/or Body. When Body is specified, client credentials and other parameters are passed within the request body in the application/x-www-form-urlencoded format. :vartype client_authentication_method: list[str or - ~api_management_client.models.ClientAuthenticationMethod] + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] :ivar token_body_parameters: Additional parameters required by the token endpoint of this authorization server represented as an array of JSON objects with name and value string properties, i.e. {"name" : "name value", "value": "a value"}. - :vartype token_body_parameters: list[~api_management_client.models.TokenBodyParameterContract] + :vartype token_body_parameters: + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] :ivar token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :vartype token_endpoint: str :ivar support_state: If true, authorization server will include state parameter from the @@ -5508,7 +5995,7 @@ class AuthorizationServerContractBaseProperties(msrest.serialization.Model): :ivar bearer_token_sending_methods: Specifies the mechanism by which access token is passed to the API. :vartype bearer_token_sending_methods: list[str or - ~api_management_client.models.BearerTokenSendingMethod] + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] :ivar resource_owner_username: Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. :vartype resource_owner_username: str @@ -5534,13 +6021,13 @@ def __init__( self, *, description: Optional[str] = None, - authorization_methods: Optional[List[Union[str, "AuthorizationMethod"]]] = None, - client_authentication_method: Optional[List[Union[str, "ClientAuthenticationMethod"]]] = None, - token_body_parameters: Optional[List["TokenBodyParameterContract"]] = None, + authorization_methods: Optional[List[Union[str, "_models.AuthorizationMethod"]]] = None, + client_authentication_method: Optional[List[Union[str, "_models.ClientAuthenticationMethod"]]] = None, + token_body_parameters: Optional[List["_models.TokenBodyParameterContract"]] = None, token_endpoint: Optional[str] = None, support_state: Optional[bool] = None, default_scope: Optional[str] = None, - bearer_token_sending_methods: Optional[List[Union[str, "BearerTokenSendingMethod"]]] = None, + bearer_token_sending_methods: Optional[List[Union[str, "_models.BearerTokenSendingMethod"]]] = None, resource_owner_username: Optional[str] = None, resource_owner_password: Optional[str] = None, **kwargs @@ -5552,18 +6039,18 @@ def __init__( :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be always present. POST is optional. :paramtype authorization_methods: list[str or - ~api_management_client.models.AuthorizationMethod] + ~azure.mgmt.apimanagement.models.AuthorizationMethod] :keyword client_authentication_method: Method of authentication supported by the token endpoint of this authorization server. Possible values are Basic and/or Body. When Body is specified, client credentials and other parameters are passed within the request body in the application/x-www-form-urlencoded format. :paramtype client_authentication_method: list[str or - ~api_management_client.models.ClientAuthenticationMethod] + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] :keyword token_body_parameters: Additional parameters required by the token endpoint of this authorization server represented as an array of JSON objects with name and value string properties, i.e. {"name" : "name value", "value": "a value"}. :paramtype token_body_parameters: - list[~api_management_client.models.TokenBodyParameterContract] + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :paramtype token_endpoint: str @@ -5578,7 +6065,7 @@ def __init__( :keyword bearer_token_sending_methods: Specifies the mechanism by which access token is passed to the API. :paramtype bearer_token_sending_methods: list[str or - ~api_management_client.models.BearerTokenSendingMethod] + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] :keyword resource_owner_username: Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. :paramtype resource_owner_username: str @@ -5608,17 +6095,19 @@ class AuthorizationServerContractProperties(AuthorizationServerContractBasePrope :vartype description: str :ivar authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be always present. POST is optional. - :vartype authorization_methods: list[str or ~api_management_client.models.AuthorizationMethod] + :vartype authorization_methods: list[str or + ~azure.mgmt.apimanagement.models.AuthorizationMethod] :ivar client_authentication_method: Method of authentication supported by the token endpoint of this authorization server. Possible values are Basic and/or Body. When Body is specified, client credentials and other parameters are passed within the request body in the application/x-www-form-urlencoded format. :vartype client_authentication_method: list[str or - ~api_management_client.models.ClientAuthenticationMethod] + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] :ivar token_body_parameters: Additional parameters required by the token endpoint of this authorization server represented as an array of JSON objects with name and value string properties, i.e. {"name" : "name value", "value": "a value"}. - :vartype token_body_parameters: list[~api_management_client.models.TokenBodyParameterContract] + :vartype token_body_parameters: + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] :ivar token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :vartype token_endpoint: str :ivar support_state: If true, authorization server will include state parameter from the @@ -5632,7 +6121,7 @@ class AuthorizationServerContractProperties(AuthorizationServerContractBasePrope :ivar bearer_token_sending_methods: Specifies the mechanism by which access token is passed to the API. :vartype bearer_token_sending_methods: list[str or - ~api_management_client.models.BearerTokenSendingMethod] + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] :ivar resource_owner_username: Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. :vartype resource_owner_username: str @@ -5641,6 +6130,12 @@ class AuthorizationServerContractProperties(AuthorizationServerContractBasePrope :vartype resource_owner_password: str :ivar display_name: Required. User-friendly authorization server name. :vartype display_name: str + :ivar use_in_test_console: If true, the authorization server may be used in the developer + portal test console. True by default if no value is provided. + :vartype use_in_test_console: bool + :ivar use_in_api_documentation: If true, the authorization server will be used in the API + documentation in the developer portal. False by default if no value is provided. + :vartype use_in_api_documentation: bool :ivar client_registration_endpoint: Required. Optional reference to a page where client or app registration for this authorization server is performed. Contains absolute URL to entity being referenced. @@ -5650,7 +6145,7 @@ class AuthorizationServerContractProperties(AuthorizationServerContractBasePrope :vartype authorization_endpoint: str :ivar grant_types: Required. Form of an authorization grant, which the client uses to request the access token. - :vartype grant_types: list[str or ~api_management_client.models.GrantType] + :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 @@ -5679,6 +6174,8 @@ class AuthorizationServerContractProperties(AuthorizationServerContractBasePrope 'resource_owner_username': {'key': 'resourceOwnerUsername', 'type': 'str'}, 'resource_owner_password': {'key': 'resourceOwnerPassword', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, + 'use_in_test_console': {'key': 'useInTestConsole', 'type': 'bool'}, + 'use_in_api_documentation': {'key': 'useInApiDocumentation', 'type': 'bool'}, 'client_registration_endpoint': {'key': 'clientRegistrationEndpoint', 'type': 'str'}, 'authorization_endpoint': {'key': 'authorizationEndpoint', 'type': 'str'}, 'grant_types': {'key': 'grantTypes', 'type': '[str]'}, @@ -5692,18 +6189,20 @@ def __init__( display_name: str, client_registration_endpoint: str, authorization_endpoint: str, - grant_types: List[Union[str, "GrantType"]], + grant_types: List[Union[str, "_models.GrantType"]], client_id: str, description: Optional[str] = None, - authorization_methods: Optional[List[Union[str, "AuthorizationMethod"]]] = None, - client_authentication_method: Optional[List[Union[str, "ClientAuthenticationMethod"]]] = None, - token_body_parameters: Optional[List["TokenBodyParameterContract"]] = None, + authorization_methods: Optional[List[Union[str, "_models.AuthorizationMethod"]]] = None, + client_authentication_method: Optional[List[Union[str, "_models.ClientAuthenticationMethod"]]] = None, + token_body_parameters: Optional[List["_models.TokenBodyParameterContract"]] = None, token_endpoint: Optional[str] = None, support_state: Optional[bool] = None, default_scope: Optional[str] = None, - bearer_token_sending_methods: Optional[List[Union[str, "BearerTokenSendingMethod"]]] = None, + bearer_token_sending_methods: Optional[List[Union[str, "_models.BearerTokenSendingMethod"]]] = None, resource_owner_username: Optional[str] = None, resource_owner_password: Optional[str] = None, + use_in_test_console: Optional[bool] = None, + use_in_api_documentation: Optional[bool] = None, client_secret: Optional[str] = None, **kwargs ): @@ -5714,18 +6213,18 @@ def __init__( :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be always present. POST is optional. :paramtype authorization_methods: list[str or - ~api_management_client.models.AuthorizationMethod] + ~azure.mgmt.apimanagement.models.AuthorizationMethod] :keyword client_authentication_method: Method of authentication supported by the token endpoint of this authorization server. Possible values are Basic and/or Body. When Body is specified, client credentials and other parameters are passed within the request body in the application/x-www-form-urlencoded format. :paramtype client_authentication_method: list[str or - ~api_management_client.models.ClientAuthenticationMethod] + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] :keyword token_body_parameters: Additional parameters required by the token endpoint of this authorization server represented as an array of JSON objects with name and value string properties, i.e. {"name" : "name value", "value": "a value"}. :paramtype token_body_parameters: - list[~api_management_client.models.TokenBodyParameterContract] + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :paramtype token_endpoint: str @@ -5740,7 +6239,7 @@ def __init__( :keyword bearer_token_sending_methods: Specifies the mechanism by which access token is passed to the API. :paramtype bearer_token_sending_methods: list[str or - ~api_management_client.models.BearerTokenSendingMethod] + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] :keyword resource_owner_username: Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. :paramtype resource_owner_username: str @@ -5749,6 +6248,12 @@ def __init__( :paramtype resource_owner_password: str :keyword display_name: Required. User-friendly authorization server name. :paramtype display_name: str + :keyword use_in_test_console: If true, the authorization server may be used in the developer + portal test console. True by default if no value is provided. + :paramtype use_in_test_console: bool + :keyword use_in_api_documentation: If true, the authorization server will be used in the API + documentation in the developer portal. False by default if no value is provided. + :paramtype use_in_api_documentation: bool :keyword client_registration_endpoint: Required. Optional reference to a page where client or app registration for this authorization server is performed. Contains absolute URL to entity being referenced. @@ -5758,7 +6263,7 @@ def __init__( :paramtype authorization_endpoint: str :keyword grant_types: Required. Form of an authorization grant, which the client uses to request the access token. - :paramtype grant_types: list[str or ~api_management_client.models.GrantType] + :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 @@ -5768,6 +6273,8 @@ def __init__( """ 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.use_in_test_console = use_in_test_console + self.use_in_api_documentation = use_in_api_documentation self.client_registration_endpoint = client_registration_endpoint self.authorization_endpoint = authorization_endpoint self.grant_types = grant_types @@ -5835,17 +6342,19 @@ class AuthorizationServerUpdateContract(Resource): :vartype description: str :ivar authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be always present. POST is optional. - :vartype authorization_methods: list[str or ~api_management_client.models.AuthorizationMethod] + :vartype authorization_methods: list[str or + ~azure.mgmt.apimanagement.models.AuthorizationMethod] :ivar client_authentication_method: Method of authentication supported by the token endpoint of this authorization server. Possible values are Basic and/or Body. When Body is specified, client credentials and other parameters are passed within the request body in the application/x-www-form-urlencoded format. :vartype client_authentication_method: list[str or - ~api_management_client.models.ClientAuthenticationMethod] + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] :ivar token_body_parameters: Additional parameters required by the token endpoint of this authorization server represented as an array of JSON objects with name and value string properties, i.e. {"name" : "name value", "value": "a value"}. - :vartype token_body_parameters: list[~api_management_client.models.TokenBodyParameterContract] + :vartype token_body_parameters: + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] :ivar token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :vartype token_endpoint: str :ivar support_state: If true, authorization server will include state parameter from the @@ -5859,7 +6368,7 @@ class AuthorizationServerUpdateContract(Resource): :ivar bearer_token_sending_methods: Specifies the mechanism by which access token is passed to the API. :vartype bearer_token_sending_methods: list[str or - ~api_management_client.models.BearerTokenSendingMethod] + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] :ivar resource_owner_username: Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. :vartype resource_owner_username: str @@ -5868,6 +6377,12 @@ class AuthorizationServerUpdateContract(Resource): :vartype resource_owner_password: str :ivar display_name: User-friendly authorization server name. :vartype display_name: str + :ivar use_in_test_console: If true, the authorization server may be used in the developer + portal test console. True by default if no value is provided. + :vartype use_in_test_console: bool + :ivar use_in_api_documentation: If true, the authorization server will be used in the API + documentation in the developer portal. False by default if no value is provided. + :vartype use_in_api_documentation: bool :ivar client_registration_endpoint: Optional reference to a page where client or app registration for this authorization server is performed. Contains absolute URL to entity being referenced. @@ -5877,7 +6392,7 @@ class AuthorizationServerUpdateContract(Resource): :vartype authorization_endpoint: str :ivar grant_types: Form of an authorization grant, which the client uses to request the access token. - :vartype grant_types: list[str or ~api_management_client.models.GrantType] + :vartype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] :ivar client_id: Client or app id registered with this authorization server. :vartype client_id: str :ivar client_secret: Client or app secret registered with this authorization server. This @@ -5908,6 +6423,8 @@ class AuthorizationServerUpdateContract(Resource): 'resource_owner_username': {'key': 'properties.resourceOwnerUsername', 'type': 'str'}, 'resource_owner_password': {'key': 'properties.resourceOwnerPassword', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'use_in_test_console': {'key': 'properties.useInTestConsole', 'type': 'bool'}, + 'use_in_api_documentation': {'key': 'properties.useInApiDocumentation', 'type': 'bool'}, 'client_registration_endpoint': {'key': 'properties.clientRegistrationEndpoint', 'type': 'str'}, 'authorization_endpoint': {'key': 'properties.authorizationEndpoint', 'type': 'str'}, 'grant_types': {'key': 'properties.grantTypes', 'type': '[str]'}, @@ -5919,19 +6436,21 @@ def __init__( self, *, description: Optional[str] = None, - authorization_methods: Optional[List[Union[str, "AuthorizationMethod"]]] = None, - client_authentication_method: Optional[List[Union[str, "ClientAuthenticationMethod"]]] = None, - token_body_parameters: Optional[List["TokenBodyParameterContract"]] = None, + authorization_methods: Optional[List[Union[str, "_models.AuthorizationMethod"]]] = None, + client_authentication_method: Optional[List[Union[str, "_models.ClientAuthenticationMethod"]]] = None, + token_body_parameters: Optional[List["_models.TokenBodyParameterContract"]] = None, token_endpoint: Optional[str] = None, support_state: Optional[bool] = None, default_scope: Optional[str] = None, - bearer_token_sending_methods: Optional[List[Union[str, "BearerTokenSendingMethod"]]] = None, + bearer_token_sending_methods: Optional[List[Union[str, "_models.BearerTokenSendingMethod"]]] = None, resource_owner_username: Optional[str] = None, resource_owner_password: Optional[str] = None, display_name: Optional[str] = None, + use_in_test_console: Optional[bool] = None, + use_in_api_documentation: Optional[bool] = None, client_registration_endpoint: Optional[str] = None, authorization_endpoint: Optional[str] = None, - grant_types: Optional[List[Union[str, "GrantType"]]] = None, + grant_types: Optional[List[Union[str, "_models.GrantType"]]] = None, client_id: Optional[str] = None, client_secret: Optional[str] = None, **kwargs @@ -5943,18 +6462,18 @@ def __init__( :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be always present. POST is optional. :paramtype authorization_methods: list[str or - ~api_management_client.models.AuthorizationMethod] + ~azure.mgmt.apimanagement.models.AuthorizationMethod] :keyword client_authentication_method: Method of authentication supported by the token endpoint of this authorization server. Possible values are Basic and/or Body. When Body is specified, client credentials and other parameters are passed within the request body in the application/x-www-form-urlencoded format. :paramtype client_authentication_method: list[str or - ~api_management_client.models.ClientAuthenticationMethod] + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] :keyword token_body_parameters: Additional parameters required by the token endpoint of this authorization server represented as an array of JSON objects with name and value string properties, i.e. {"name" : "name value", "value": "a value"}. :paramtype token_body_parameters: - list[~api_management_client.models.TokenBodyParameterContract] + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :paramtype token_endpoint: str @@ -5969,7 +6488,7 @@ def __init__( :keyword bearer_token_sending_methods: Specifies the mechanism by which access token is passed to the API. :paramtype bearer_token_sending_methods: list[str or - ~api_management_client.models.BearerTokenSendingMethod] + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] :keyword resource_owner_username: Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. :paramtype resource_owner_username: str @@ -5978,6 +6497,12 @@ def __init__( :paramtype resource_owner_password: str :keyword display_name: User-friendly authorization server name. :paramtype display_name: str + :keyword use_in_test_console: If true, the authorization server may be used in the developer + portal test console. True by default if no value is provided. + :paramtype use_in_test_console: bool + :keyword use_in_api_documentation: If true, the authorization server will be used in the API + documentation in the developer portal. False by default if no value is provided. + :paramtype use_in_api_documentation: bool :keyword client_registration_endpoint: Optional reference to a page where client or app registration for this authorization server is performed. Contains absolute URL to entity being referenced. @@ -5987,7 +6512,7 @@ def __init__( :paramtype authorization_endpoint: str :keyword grant_types: Form of an authorization grant, which the client uses to request the access token. - :paramtype grant_types: list[str or ~api_management_client.models.GrantType] + :paramtype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] :keyword client_id: Client or app id registered with this authorization server. :paramtype client_id: str :keyword client_secret: Client or app secret registered with this authorization server. This @@ -6007,6 +6532,8 @@ def __init__( self.resource_owner_username = resource_owner_username self.resource_owner_password = resource_owner_password self.display_name = display_name + self.use_in_test_console = use_in_test_console + self.use_in_api_documentation = use_in_api_documentation self.client_registration_endpoint = client_registration_endpoint self.authorization_endpoint = authorization_endpoint self.grant_types = grant_types @@ -6021,17 +6548,19 @@ class AuthorizationServerUpdateContractProperties(AuthorizationServerContractBas :vartype description: str :ivar authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be always present. POST is optional. - :vartype authorization_methods: list[str or ~api_management_client.models.AuthorizationMethod] + :vartype authorization_methods: list[str or + ~azure.mgmt.apimanagement.models.AuthorizationMethod] :ivar client_authentication_method: Method of authentication supported by the token endpoint of this authorization server. Possible values are Basic and/or Body. When Body is specified, client credentials and other parameters are passed within the request body in the application/x-www-form-urlencoded format. :vartype client_authentication_method: list[str or - ~api_management_client.models.ClientAuthenticationMethod] + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] :ivar token_body_parameters: Additional parameters required by the token endpoint of this authorization server represented as an array of JSON objects with name and value string properties, i.e. {"name" : "name value", "value": "a value"}. - :vartype token_body_parameters: list[~api_management_client.models.TokenBodyParameterContract] + :vartype token_body_parameters: + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] :ivar token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :vartype token_endpoint: str :ivar support_state: If true, authorization server will include state parameter from the @@ -6045,7 +6574,7 @@ class AuthorizationServerUpdateContractProperties(AuthorizationServerContractBas :ivar bearer_token_sending_methods: Specifies the mechanism by which access token is passed to the API. :vartype bearer_token_sending_methods: list[str or - ~api_management_client.models.BearerTokenSendingMethod] + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] :ivar resource_owner_username: Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. :vartype resource_owner_username: str @@ -6054,6 +6583,12 @@ class AuthorizationServerUpdateContractProperties(AuthorizationServerContractBas :vartype resource_owner_password: str :ivar display_name: User-friendly authorization server name. :vartype display_name: str + :ivar use_in_test_console: If true, the authorization server may be used in the developer + portal test console. True by default if no value is provided. + :vartype use_in_test_console: bool + :ivar use_in_api_documentation: If true, the authorization server will be used in the API + documentation in the developer portal. False by default if no value is provided. + :vartype use_in_api_documentation: bool :ivar client_registration_endpoint: Optional reference to a page where client or app registration for this authorization server is performed. Contains absolute URL to entity being referenced. @@ -6063,7 +6598,7 @@ class AuthorizationServerUpdateContractProperties(AuthorizationServerContractBas :vartype authorization_endpoint: str :ivar grant_types: Form of an authorization grant, which the client uses to request the access token. - :vartype grant_types: list[str or ~api_management_client.models.GrantType] + :vartype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] :ivar client_id: Client or app id registered with this authorization server. :vartype client_id: str :ivar client_secret: Client or app secret registered with this authorization server. This @@ -6088,6 +6623,8 @@ class AuthorizationServerUpdateContractProperties(AuthorizationServerContractBas 'resource_owner_username': {'key': 'resourceOwnerUsername', 'type': 'str'}, 'resource_owner_password': {'key': 'resourceOwnerPassword', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, + 'use_in_test_console': {'key': 'useInTestConsole', 'type': 'bool'}, + 'use_in_api_documentation': {'key': 'useInApiDocumentation', 'type': 'bool'}, 'client_registration_endpoint': {'key': 'clientRegistrationEndpoint', 'type': 'str'}, 'authorization_endpoint': {'key': 'authorizationEndpoint', 'type': 'str'}, 'grant_types': {'key': 'grantTypes', 'type': '[str]'}, @@ -6099,19 +6636,21 @@ def __init__( self, *, description: Optional[str] = None, - authorization_methods: Optional[List[Union[str, "AuthorizationMethod"]]] = None, - client_authentication_method: Optional[List[Union[str, "ClientAuthenticationMethod"]]] = None, - token_body_parameters: Optional[List["TokenBodyParameterContract"]] = None, + authorization_methods: Optional[List[Union[str, "_models.AuthorizationMethod"]]] = None, + client_authentication_method: Optional[List[Union[str, "_models.ClientAuthenticationMethod"]]] = None, + token_body_parameters: Optional[List["_models.TokenBodyParameterContract"]] = None, token_endpoint: Optional[str] = None, support_state: Optional[bool] = None, default_scope: Optional[str] = None, - bearer_token_sending_methods: Optional[List[Union[str, "BearerTokenSendingMethod"]]] = None, + bearer_token_sending_methods: Optional[List[Union[str, "_models.BearerTokenSendingMethod"]]] = None, resource_owner_username: Optional[str] = None, resource_owner_password: Optional[str] = None, display_name: Optional[str] = None, + use_in_test_console: Optional[bool] = None, + use_in_api_documentation: Optional[bool] = None, client_registration_endpoint: Optional[str] = None, authorization_endpoint: Optional[str] = None, - grant_types: Optional[List[Union[str, "GrantType"]]] = None, + grant_types: Optional[List[Union[str, "_models.GrantType"]]] = None, client_id: Optional[str] = None, client_secret: Optional[str] = None, **kwargs @@ -6123,18 +6662,18 @@ def __init__( :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be always present. POST is optional. :paramtype authorization_methods: list[str or - ~api_management_client.models.AuthorizationMethod] + ~azure.mgmt.apimanagement.models.AuthorizationMethod] :keyword client_authentication_method: Method of authentication supported by the token endpoint of this authorization server. Possible values are Basic and/or Body. When Body is specified, client credentials and other parameters are passed within the request body in the application/x-www-form-urlencoded format. :paramtype client_authentication_method: list[str or - ~api_management_client.models.ClientAuthenticationMethod] + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] :keyword token_body_parameters: Additional parameters required by the token endpoint of this authorization server represented as an array of JSON objects with name and value string properties, i.e. {"name" : "name value", "value": "a value"}. :paramtype token_body_parameters: - list[~api_management_client.models.TokenBodyParameterContract] + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :paramtype token_endpoint: str @@ -6149,7 +6688,7 @@ def __init__( :keyword bearer_token_sending_methods: Specifies the mechanism by which access token is passed to the API. :paramtype bearer_token_sending_methods: list[str or - ~api_management_client.models.BearerTokenSendingMethod] + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] :keyword resource_owner_username: Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. :paramtype resource_owner_username: str @@ -6158,6 +6697,12 @@ def __init__( :paramtype resource_owner_password: str :keyword display_name: User-friendly authorization server name. :paramtype display_name: str + :keyword use_in_test_console: If true, the authorization server may be used in the developer + portal test console. True by default if no value is provided. + :paramtype use_in_test_console: bool + :keyword use_in_api_documentation: If true, the authorization server will be used in the API + documentation in the developer portal. False by default if no value is provided. + :paramtype use_in_api_documentation: bool :keyword client_registration_endpoint: Optional reference to a page where client or app registration for this authorization server is performed. Contains absolute URL to entity being referenced. @@ -6167,7 +6712,7 @@ def __init__( :paramtype authorization_endpoint: str :keyword grant_types: Form of an authorization grant, which the client uses to request the access token. - :paramtype grant_types: list[str or ~api_management_client.models.GrantType] + :paramtype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] :keyword client_id: Client or app id registered with this authorization server. :paramtype client_id: str :keyword client_secret: Client or app secret registered with this authorization server. This @@ -6177,6 +6722,8 @@ def __init__( """ 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.use_in_test_console = use_in_test_console + self.use_in_api_documentation = use_in_api_documentation self.client_registration_endpoint = client_registration_endpoint self.authorization_endpoint = authorization_endpoint self.grant_types = grant_types @@ -6234,13 +6781,13 @@ class BackendBaseParameters(msrest.serialization.Model): Resource Id of Logic Apps, Function Apps or API Apps. :vartype resource_id: str :ivar properties: Backend Properties contract. - :vartype properties: ~api_management_client.models.BackendProperties + :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties :ivar credentials: Backend Credentials Contract Properties. - :vartype credentials: ~api_management_client.models.BackendCredentialsContract + :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :ivar proxy: Backend Proxy Contract Properties. - :vartype proxy: ~api_management_client.models.BackendProxyContract + :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :ivar tls: Backend TLS Properties. - :vartype tls: ~api_management_client.models.BackendTlsProperties + :vartype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties """ _validation = { @@ -6265,10 +6812,10 @@ def __init__( title: Optional[str] = None, description: Optional[str] = None, resource_id: Optional[str] = None, - properties: Optional["BackendProperties"] = None, - credentials: Optional["BackendCredentialsContract"] = None, - proxy: Optional["BackendProxyContract"] = None, - tls: Optional["BackendTlsProperties"] = None, + properties: Optional["_models.BackendProperties"] = None, + credentials: Optional["_models.BackendCredentialsContract"] = None, + proxy: Optional["_models.BackendProxyContract"] = None, + tls: Optional["_models.BackendTlsProperties"] = None, **kwargs ): """ @@ -6280,13 +6827,13 @@ def __init__( Arm Resource Id of Logic Apps, Function Apps or API Apps. :paramtype resource_id: str :keyword properties: Backend Properties contract. - :paramtype properties: ~api_management_client.models.BackendProperties + :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties :keyword credentials: Backend Credentials Contract Properties. - :paramtype credentials: ~api_management_client.models.BackendCredentialsContract + :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :keyword proxy: Backend Proxy Contract Properties. - :paramtype proxy: ~api_management_client.models.BackendProxyContract + :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :keyword tls: Backend TLS Properties. - :paramtype tls: ~api_management_client.models.BackendTlsProperties + :paramtype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties """ super(BackendBaseParameters, self).__init__(**kwargs) self.title = title @@ -6302,7 +6849,7 @@ class BackendCollection(msrest.serialization.Model): """Paged Backend list representation. :ivar value: Backend values. - :vartype value: list[~api_management_client.models.BackendContract] + :vartype value: list[~azure.mgmt.apimanagement.models.BackendContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -6318,14 +6865,14 @@ class BackendCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["BackendContract"]] = None, + value: Optional[List["_models.BackendContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Backend values. - :paramtype value: list[~api_management_client.models.BackendContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.BackendContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -6358,17 +6905,17 @@ class BackendContract(Resource): Resource Id of Logic Apps, Function Apps or API Apps. :vartype resource_id: str :ivar properties: Backend Properties contract. - :vartype properties: ~api_management_client.models.BackendProperties + :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties :ivar credentials: Backend Credentials Contract Properties. - :vartype credentials: ~api_management_client.models.BackendCredentialsContract + :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :ivar proxy: Backend Proxy Contract Properties. - :vartype proxy: ~api_management_client.models.BackendProxyContract + :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :ivar tls: Backend TLS Properties. - :vartype tls: ~api_management_client.models.BackendTlsProperties + :vartype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties :ivar url: Runtime Url of the Backend. :vartype url: str - :ivar protocol: Backend communication protocol. Possible values include: "http", "soap". - :vartype protocol: str or ~api_management_client.models.BackendProtocol + :ivar protocol: Backend communication protocol. Known values are: "http", "soap". + :vartype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol """ _validation = { @@ -6402,12 +6949,12 @@ def __init__( title: Optional[str] = None, description: Optional[str] = None, resource_id: Optional[str] = None, - properties: Optional["BackendProperties"] = None, - credentials: Optional["BackendCredentialsContract"] = None, - proxy: Optional["BackendProxyContract"] = None, - tls: Optional["BackendTlsProperties"] = None, + properties: Optional["_models.BackendProperties"] = None, + credentials: Optional["_models.BackendCredentialsContract"] = None, + proxy: Optional["_models.BackendProxyContract"] = None, + tls: Optional["_models.BackendTlsProperties"] = None, url: Optional[str] = None, - protocol: Optional[Union[str, "BackendProtocol"]] = None, + protocol: Optional[Union[str, "_models.BackendProtocol"]] = None, **kwargs ): """ @@ -6419,17 +6966,17 @@ def __init__( Arm Resource Id of Logic Apps, Function Apps or API Apps. :paramtype resource_id: str :keyword properties: Backend Properties contract. - :paramtype properties: ~api_management_client.models.BackendProperties + :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties :keyword credentials: Backend Credentials Contract Properties. - :paramtype credentials: ~api_management_client.models.BackendCredentialsContract + :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :keyword proxy: Backend Proxy Contract Properties. - :paramtype proxy: ~api_management_client.models.BackendProxyContract + :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :keyword tls: Backend TLS Properties. - :paramtype tls: ~api_management_client.models.BackendTlsProperties + :paramtype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties :keyword url: Runtime Url of the Backend. :paramtype url: str - :keyword protocol: Backend communication protocol. Possible values include: "http", "soap". - :paramtype protocol: str or ~api_management_client.models.BackendProtocol + :keyword protocol: Backend communication protocol. Known values are: "http", "soap". + :paramtype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol """ super(BackendContract, self).__init__(**kwargs) self.title = title @@ -6456,18 +7003,17 @@ class BackendContractProperties(BackendBaseParameters): Resource Id of Logic Apps, Function Apps or API Apps. :vartype resource_id: str :ivar properties: Backend Properties contract. - :vartype properties: ~api_management_client.models.BackendProperties + :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties :ivar credentials: Backend Credentials Contract Properties. - :vartype credentials: ~api_management_client.models.BackendCredentialsContract + :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :ivar proxy: Backend Proxy Contract Properties. - :vartype proxy: ~api_management_client.models.BackendProxyContract + :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :ivar tls: Backend TLS Properties. - :vartype tls: ~api_management_client.models.BackendTlsProperties + :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". - :vartype protocol: str or ~api_management_client.models.BackendProtocol + :ivar protocol: Required. Backend communication protocol. Known values are: "http", "soap". + :vartype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol """ _validation = { @@ -6494,14 +7040,14 @@ def __init__( self, *, url: str, - protocol: Union[str, "BackendProtocol"], + protocol: Union[str, "_models.BackendProtocol"], title: Optional[str] = None, description: Optional[str] = None, resource_id: Optional[str] = None, - properties: Optional["BackendProperties"] = None, - credentials: Optional["BackendCredentialsContract"] = None, - proxy: Optional["BackendProxyContract"] = None, - tls: Optional["BackendTlsProperties"] = None, + properties: Optional["_models.BackendProperties"] = None, + credentials: Optional["_models.BackendCredentialsContract"] = None, + proxy: Optional["_models.BackendProxyContract"] = None, + tls: Optional["_models.BackendTlsProperties"] = None, **kwargs ): """ @@ -6513,18 +7059,17 @@ def __init__( Arm Resource Id of Logic Apps, Function Apps or API Apps. :paramtype resource_id: str :keyword properties: Backend Properties contract. - :paramtype properties: ~api_management_client.models.BackendProperties + :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties :keyword credentials: Backend Credentials Contract Properties. - :paramtype credentials: ~api_management_client.models.BackendCredentialsContract + :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :keyword proxy: Backend Proxy Contract Properties. - :paramtype proxy: ~api_management_client.models.BackendProxyContract + :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :keyword tls: Backend TLS Properties. - :paramtype tls: ~api_management_client.models.BackendTlsProperties + :paramtype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties :keyword url: Required. Runtime Url of the Backend. :paramtype url: str - :keyword protocol: Required. Backend communication protocol. Possible values include: "http", - "soap". - :paramtype protocol: str or ~api_management_client.models.BackendProtocol + :keyword protocol: Required. Backend communication protocol. Known values are: "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 @@ -6544,7 +7089,7 @@ class BackendCredentialsContract(msrest.serialization.Model): :ivar header: Header Parameter description. :vartype header: dict[str, list[str]] :ivar authorization: Authorization header authentication. - :vartype authorization: ~api_management_client.models.BackendAuthorizationHeaderCredentials + :vartype authorization: ~azure.mgmt.apimanagement.models.BackendAuthorizationHeaderCredentials """ _validation = { @@ -6567,7 +7112,7 @@ def __init__( certificate: Optional[List[str]] = None, query: Optional[Dict[str, List[str]]] = None, header: Optional[Dict[str, List[str]]] = None, - authorization: Optional["BackendAuthorizationHeaderCredentials"] = None, + authorization: Optional["_models.BackendAuthorizationHeaderCredentials"] = None, **kwargs ): """ @@ -6581,7 +7126,8 @@ def __init__( :keyword header: Header Parameter description. :paramtype header: dict[str, list[str]] :keyword authorization: Authorization header authentication. - :paramtype authorization: ~api_management_client.models.BackendAuthorizationHeaderCredentials + :paramtype authorization: + ~azure.mgmt.apimanagement.models.BackendAuthorizationHeaderCredentials """ super(BackendCredentialsContract, self).__init__(**kwargs) self.certificate_ids = certificate_ids @@ -6596,7 +7142,7 @@ class BackendProperties(msrest.serialization.Model): :ivar service_fabric_cluster: Backend Service Fabric Cluster Properties. :vartype service_fabric_cluster: - ~api_management_client.models.BackendServiceFabricClusterProperties + ~azure.mgmt.apimanagement.models.BackendServiceFabricClusterProperties """ _attribute_map = { @@ -6606,13 +7152,13 @@ class BackendProperties(msrest.serialization.Model): def __init__( self, *, - service_fabric_cluster: Optional["BackendServiceFabricClusterProperties"] = None, + service_fabric_cluster: Optional["_models.BackendServiceFabricClusterProperties"] = None, **kwargs ): """ :keyword service_fabric_cluster: Backend Service Fabric Cluster Properties. :paramtype service_fabric_cluster: - ~api_management_client.models.BackendServiceFabricClusterProperties + ~azure.mgmt.apimanagement.models.BackendServiceFabricClusterProperties """ super(BackendProperties, self).__init__(**kwargs) self.service_fabric_cluster = service_fabric_cluster @@ -6730,7 +7276,7 @@ class BackendServiceFabricClusterProperties(msrest.serialization.Model): uses for tls communication. :vartype server_certificate_thumbprints: list[str] :ivar server_x509_names: Server X509 Certificate Names Collection. - :vartype server_x509_names: list[~api_management_client.models.X509CertificateName] + :vartype server_x509_names: list[~azure.mgmt.apimanagement.models.X509CertificateName] """ _validation = { @@ -6754,7 +7300,7 @@ def __init__( client_certificatethumbprint: Optional[str] = None, max_partition_resolution_retries: Optional[int] = None, server_certificate_thumbprints: Optional[List[str]] = None, - server_x509_names: Optional[List["X509CertificateName"]] = None, + server_x509_names: Optional[List["_models.X509CertificateName"]] = None, **kwargs ): """ @@ -6772,7 +7318,7 @@ def __init__( uses for tls communication. :paramtype server_certificate_thumbprints: list[str] :keyword server_x509_names: Server X509 Certificate Names Collection. - :paramtype server_x509_names: list[~api_management_client.models.X509CertificateName] + :paramtype server_x509_names: list[~azure.mgmt.apimanagement.models.X509CertificateName] """ super(BackendServiceFabricClusterProperties, self).__init__(**kwargs) self.client_certificate_id = client_certificate_id @@ -6830,17 +7376,17 @@ class BackendUpdateParameterProperties(BackendBaseParameters): Resource Id of Logic Apps, Function Apps or API Apps. :vartype resource_id: str :ivar properties: Backend Properties contract. - :vartype properties: ~api_management_client.models.BackendProperties + :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties :ivar credentials: Backend Credentials Contract Properties. - :vartype credentials: ~api_management_client.models.BackendCredentialsContract + :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :ivar proxy: Backend Proxy Contract Properties. - :vartype proxy: ~api_management_client.models.BackendProxyContract + :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :ivar tls: Backend TLS Properties. - :vartype tls: ~api_management_client.models.BackendTlsProperties + :vartype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties :ivar url: Runtime Url of the Backend. :vartype url: str - :ivar protocol: Backend communication protocol. Possible values include: "http", "soap". - :vartype protocol: str or ~api_management_client.models.BackendProtocol + :ivar protocol: Backend communication protocol. Known values are: "http", "soap". + :vartype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol """ _validation = { @@ -6868,12 +7414,12 @@ def __init__( title: Optional[str] = None, description: Optional[str] = None, resource_id: Optional[str] = None, - properties: Optional["BackendProperties"] = None, - credentials: Optional["BackendCredentialsContract"] = None, - proxy: Optional["BackendProxyContract"] = None, - tls: Optional["BackendTlsProperties"] = None, + properties: Optional["_models.BackendProperties"] = None, + credentials: Optional["_models.BackendCredentialsContract"] = None, + proxy: Optional["_models.BackendProxyContract"] = None, + tls: Optional["_models.BackendTlsProperties"] = None, url: Optional[str] = None, - protocol: Optional[Union[str, "BackendProtocol"]] = None, + protocol: Optional[Union[str, "_models.BackendProtocol"]] = None, **kwargs ): """ @@ -6885,17 +7431,17 @@ def __init__( Arm Resource Id of Logic Apps, Function Apps or API Apps. :paramtype resource_id: str :keyword properties: Backend Properties contract. - :paramtype properties: ~api_management_client.models.BackendProperties + :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties :keyword credentials: Backend Credentials Contract Properties. - :paramtype credentials: ~api_management_client.models.BackendCredentialsContract + :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :keyword proxy: Backend Proxy Contract Properties. - :paramtype proxy: ~api_management_client.models.BackendProxyContract + :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :keyword tls: Backend TLS Properties. - :paramtype tls: ~api_management_client.models.BackendTlsProperties + :paramtype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties :keyword url: Runtime Url of the Backend. :paramtype url: str - :keyword protocol: Backend communication protocol. Possible values include: "http", "soap". - :paramtype protocol: str or ~api_management_client.models.BackendProtocol + :keyword protocol: Backend communication protocol. Known values are: "http", "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 @@ -6913,17 +7459,17 @@ class BackendUpdateParameters(msrest.serialization.Model): Resource Id of Logic Apps, Function Apps or API Apps. :vartype resource_id: str :ivar properties: Backend Properties contract. - :vartype properties: ~api_management_client.models.BackendProperties + :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties :ivar credentials: Backend Credentials Contract Properties. - :vartype credentials: ~api_management_client.models.BackendCredentialsContract + :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :ivar proxy: Backend Proxy Contract Properties. - :vartype proxy: ~api_management_client.models.BackendProxyContract + :vartype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :ivar tls: Backend TLS Properties. - :vartype tls: ~api_management_client.models.BackendTlsProperties + :vartype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties :ivar url: Runtime Url of the Backend. :vartype url: str - :ivar protocol: Backend communication protocol. Possible values include: "http", "soap". - :vartype protocol: str or ~api_management_client.models.BackendProtocol + :ivar protocol: Backend communication protocol. Known values are: "http", "soap". + :vartype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol """ _validation = { @@ -6951,12 +7497,12 @@ def __init__( title: Optional[str] = None, description: Optional[str] = None, resource_id: Optional[str] = None, - properties: Optional["BackendProperties"] = None, - credentials: Optional["BackendCredentialsContract"] = None, - proxy: Optional["BackendProxyContract"] = None, - tls: Optional["BackendTlsProperties"] = None, + properties: Optional["_models.BackendProperties"] = None, + credentials: Optional["_models.BackendCredentialsContract"] = None, + proxy: Optional["_models.BackendProxyContract"] = None, + tls: Optional["_models.BackendTlsProperties"] = None, url: Optional[str] = None, - protocol: Optional[Union[str, "BackendProtocol"]] = None, + protocol: Optional[Union[str, "_models.BackendProtocol"]] = None, **kwargs ): """ @@ -6968,17 +7514,17 @@ def __init__( Arm Resource Id of Logic Apps, Function Apps or API Apps. :paramtype resource_id: str :keyword properties: Backend Properties contract. - :paramtype properties: ~api_management_client.models.BackendProperties + :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties :keyword credentials: Backend Credentials Contract Properties. - :paramtype credentials: ~api_management_client.models.BackendCredentialsContract + :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract :keyword proxy: Backend Proxy Contract Properties. - :paramtype proxy: ~api_management_client.models.BackendProxyContract + :paramtype proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract :keyword tls: Backend TLS Properties. - :paramtype tls: ~api_management_client.models.BackendTlsProperties + :paramtype tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties :keyword url: Runtime Url of the Backend. :paramtype url: str - :keyword protocol: Backend communication protocol. Possible values include: "http", "soap". - :paramtype protocol: str or ~api_management_client.models.BackendProtocol + :keyword protocol: Backend communication protocol. Known values are: "http", "soap". + :paramtype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol """ super(BackendUpdateParameters, self).__init__(**kwargs) self.title = title @@ -7025,7 +7571,7 @@ class CacheCollection(msrest.serialization.Model): """Paged Caches list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.CacheContract] + :vartype value: list[~azure.mgmt.apimanagement.models.CacheContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -7041,14 +7587,14 @@ class CacheCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["CacheContract"]] = None, + value: Optional[List["_models.CacheContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.CacheContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.CacheContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -7190,7 +7736,7 @@ class CertificateCollection(msrest.serialization.Model): """Paged Certificates list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.CertificateContract] + :vartype value: list[~azure.mgmt.apimanagement.models.CertificateContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -7206,14 +7752,14 @@ class CertificateCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["CertificateContract"]] = None, + value: Optional[List["_models.CertificateContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.CertificateContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.CertificateContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -7235,11 +7781,11 @@ class CertificateConfiguration(msrest.serialization.Model): :ivar certificate_password: Certificate Password. :vartype certificate_password: str :ivar store_name: Required. The System.Security.Cryptography.x509certificates.StoreName - certificate store location. Only Root and CertificateAuthority are valid locations. Possible - values include: "CertificateAuthority", "Root". - :vartype store_name: str or ~api_management_client.models.CertificateConfigurationStoreName + certificate store location. Only Root and CertificateAuthority are valid locations. Known + values are: "CertificateAuthority", "Root". + :vartype store_name: str or ~azure.mgmt.apimanagement.models.CertificateConfigurationStoreName :ivar certificate: Certificate information. - :vartype certificate: ~api_management_client.models.CertificateInformation + :vartype certificate: ~azure.mgmt.apimanagement.models.CertificateInformation """ _validation = { @@ -7256,10 +7802,10 @@ class CertificateConfiguration(msrest.serialization.Model): def __init__( self, *, - store_name: Union[str, "CertificateConfigurationStoreName"], + store_name: Union[str, "_models.CertificateConfigurationStoreName"], encoded_certificate: Optional[str] = None, certificate_password: Optional[str] = None, - certificate: Optional["CertificateInformation"] = None, + certificate: Optional["_models.CertificateInformation"] = None, **kwargs ): """ @@ -7268,11 +7814,12 @@ def __init__( :keyword certificate_password: Certificate Password. :paramtype certificate_password: str :keyword store_name: Required. The System.Security.Cryptography.x509certificates.StoreName - certificate store location. Only Root and CertificateAuthority are valid locations. Possible - values include: "CertificateAuthority", "Root". - :paramtype store_name: str or ~api_management_client.models.CertificateConfigurationStoreName + certificate store location. Only Root and CertificateAuthority are valid locations. Known + values are: "CertificateAuthority", "Root". + :paramtype store_name: str or + ~azure.mgmt.apimanagement.models.CertificateConfigurationStoreName :keyword certificate: Certificate information. - :paramtype certificate: ~api_management_client.models.CertificateInformation + :paramtype certificate: ~azure.mgmt.apimanagement.models.CertificateInformation """ super(CertificateConfiguration, self).__init__(**kwargs) self.encoded_certificate = encoded_certificate @@ -7302,7 +7849,7 @@ class CertificateContract(Resource): format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. :vartype expiration_date: ~datetime.datetime :ivar key_vault: KeyVault location details of the certificate. - :vartype key_vault: ~api_management_client.models.KeyVaultContractProperties + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties """ _validation = { @@ -7327,7 +7874,7 @@ def __init__( subject: Optional[str] = None, thumbprint: Optional[str] = None, expiration_date: Optional[datetime.datetime] = None, - key_vault: Optional["KeyVaultContractProperties"] = None, + key_vault: Optional["_models.KeyVaultContractProperties"] = None, **kwargs ): """ @@ -7339,7 +7886,7 @@ def __init__( following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. :paramtype expiration_date: ~datetime.datetime :keyword key_vault: KeyVault location details of the certificate. - :paramtype key_vault: ~api_management_client.models.KeyVaultContractProperties + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties """ super(CertificateContract, self).__init__(**kwargs) self.subject = subject @@ -7356,7 +7903,7 @@ class CertificateCreateOrUpdateParameters(msrest.serialization.Model): :ivar password: Password for the Certificate. :vartype password: str :ivar key_vault: KeyVault location details of the certificate. - :vartype key_vault: ~api_management_client.models.KeyVaultContractCreateProperties + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ _attribute_map = { @@ -7370,7 +7917,7 @@ def __init__( *, data: Optional[str] = None, password: Optional[str] = None, - key_vault: Optional["KeyVaultContractCreateProperties"] = None, + key_vault: Optional["_models.KeyVaultContractCreateProperties"] = None, **kwargs ): """ @@ -7379,7 +7926,7 @@ def __init__( :keyword password: Password for the Certificate. :paramtype password: str :keyword key_vault: KeyVault location details of the certificate. - :paramtype key_vault: ~api_management_client.models.KeyVaultContractCreateProperties + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ super(CertificateCreateOrUpdateParameters, self).__init__(**kwargs) self.data = data @@ -7467,19 +8014,19 @@ class ConnectivityCheckRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar source: Required. Definitions about the connectivity check origin. - :vartype source: ~api_management_client.models.ConnectivityCheckRequestSource + :vartype source: ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestSource :ivar destination: Required. The connectivity check operation destination. - :vartype destination: ~api_management_client.models.ConnectivityCheckRequestDestination - :ivar preferred_ip_version: The IP version to be used. Only IPv4 is supported for now. Possible - values include: "IPv4". - :vartype preferred_ip_version: str or ~api_management_client.models.PreferredIPVersion + :vartype destination: ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestDestination + :ivar preferred_ip_version: The IP version to be used. Only IPv4 is supported for now. Known + values are: "IPv4". + :vartype preferred_ip_version: str or ~azure.mgmt.apimanagement.models.PreferredIPVersion :ivar protocol: The request's protocol. Specific protocol configuration can be available based - on this selection. The specified destination address must be coherent with this value. Possible - values include: "TCP", "HTTP", "HTTPS". - :vartype protocol: str or ~api_management_client.models.ConnectivityCheckProtocol + on this selection. The specified destination address must be coherent with this value. Known + values are: "TCP", "HTTP", "HTTPS". + :vartype protocol: str or ~azure.mgmt.apimanagement.models.ConnectivityCheckProtocol :ivar protocol_configuration: Protocol-specific configuration. :vartype protocol_configuration: - ~api_management_client.models.ConnectivityCheckRequestProtocolConfiguration + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfiguration """ _validation = { @@ -7498,28 +8045,28 @@ class ConnectivityCheckRequest(msrest.serialization.Model): def __init__( self, *, - source: "ConnectivityCheckRequestSource", - destination: "ConnectivityCheckRequestDestination", - preferred_ip_version: Optional[Union[str, "PreferredIPVersion"]] = None, - protocol: Optional[Union[str, "ConnectivityCheckProtocol"]] = None, - protocol_configuration: Optional["ConnectivityCheckRequestProtocolConfiguration"] = None, + source: "_models.ConnectivityCheckRequestSource", + destination: "_models.ConnectivityCheckRequestDestination", + preferred_ip_version: Optional[Union[str, "_models.PreferredIPVersion"]] = None, + protocol: Optional[Union[str, "_models.ConnectivityCheckProtocol"]] = None, + protocol_configuration: Optional["_models.ConnectivityCheckRequestProtocolConfiguration"] = None, **kwargs ): """ :keyword source: Required. Definitions about the connectivity check origin. - :paramtype source: ~api_management_client.models.ConnectivityCheckRequestSource + :paramtype source: ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestSource :keyword destination: Required. The connectivity check operation destination. - :paramtype destination: ~api_management_client.models.ConnectivityCheckRequestDestination - :keyword preferred_ip_version: The IP version to be used. Only IPv4 is supported for now. - Possible values include: "IPv4". - :paramtype preferred_ip_version: str or ~api_management_client.models.PreferredIPVersion + :paramtype destination: ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestDestination + :keyword preferred_ip_version: The IP version to be used. Only IPv4 is supported for now. Known + values are: "IPv4". + :paramtype preferred_ip_version: str or ~azure.mgmt.apimanagement.models.PreferredIPVersion :keyword protocol: The request's protocol. Specific protocol configuration can be available based on this selection. The specified destination address must be coherent with this value. - Possible values include: "TCP", "HTTP", "HTTPS". - :paramtype protocol: str or ~api_management_client.models.ConnectivityCheckProtocol + Known values are: "TCP", "HTTP", "HTTPS". + :paramtype protocol: str or ~azure.mgmt.apimanagement.models.ConnectivityCheckProtocol :keyword protocol_configuration: Protocol-specific configuration. :paramtype protocol_configuration: - ~api_management_client.models.ConnectivityCheckRequestProtocolConfiguration + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfiguration """ super(ConnectivityCheckRequest, self).__init__(**kwargs) self.source = source @@ -7573,7 +8120,7 @@ class ConnectivityCheckRequestProtocolConfiguration(msrest.serialization.Model): :ivar http_configuration: Configuration for HTTP or HTTPS requests. :vartype http_configuration: - ~api_management_client.models.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration """ _attribute_map = { @@ -7583,13 +8130,13 @@ class ConnectivityCheckRequestProtocolConfiguration(msrest.serialization.Model): def __init__( self, *, - http_configuration: Optional["ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration"] = None, + http_configuration: Optional["_models.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration"] = None, **kwargs ): """ :keyword http_configuration: Configuration for HTTP or HTTPS requests. :paramtype http_configuration: - ~api_management_client.models.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration """ super(ConnectivityCheckRequestProtocolConfiguration, self).__init__(**kwargs) self.http_configuration = http_configuration @@ -7598,12 +8145,12 @@ def __init__( 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 ~api_management_client.models.Method + :ivar method: The HTTP method to be used. Known values are: "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[~api_management_client.models.HTTPHeader] + :vartype headers: list[~azure.mgmt.apimanagement.models.HTTPHeader] """ _attribute_map = { @@ -7615,19 +8162,19 @@ class ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration(msrest.seri def __init__( self, *, - method: Optional[Union[str, "Method"]] = None, + method: Optional[Union[str, "_models.Method"]] = None, valid_status_codes: Optional[List[int]] = None, - headers: Optional[List["HTTPHeader"]] = None, + headers: Optional[List["_models.HTTPHeader"]] = None, **kwargs ): """ - :keyword method: The HTTP method to be used. Possible values include: "GET", "POST". - :paramtype method: str or ~api_management_client.models.Method + :keyword method: The HTTP method to be used. Known values are: "GET", "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[~api_management_client.models.HTTPHeader] + :paramtype headers: list[~azure.mgmt.apimanagement.models.HTTPHeader] """ super(ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration, self).__init__(**kwargs) self.method = method @@ -7681,10 +8228,10 @@ class ConnectivityCheckResponse(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar hops: List of hops between the source and the destination. - :vartype hops: list[~api_management_client.models.ConnectivityHop] - :ivar connection_status: The connection status. Possible values include: "Unknown", - "Connected", "Disconnected", "Degraded". - :vartype connection_status: str or ~api_management_client.models.ConnectionStatus + :vartype hops: list[~azure.mgmt.apimanagement.models.ConnectivityHop] + :ivar connection_status: The connection status. Known values are: "Unknown", "Connected", + "Disconnected", "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. @@ -7749,7 +8296,7 @@ class ConnectivityHop(msrest.serialization.Model): :ivar next_hop_ids: List of next hop identifiers. :vartype next_hop_ids: list[str] :ivar issues: List of issues. - :vartype issues: list[~api_management_client.models.ConnectivityIssue] + :vartype issues: list[~azure.mgmt.apimanagement.models.ConnectivityIssue] """ _validation = { @@ -7790,14 +8337,14 @@ class ConnectivityIssue(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar origin: The origin of the issue. Possible values include: "Local", "Inbound", "Outbound". - :vartype origin: str or ~api_management_client.models.Origin - :ivar severity: The severity of the issue. Possible values include: "Error", "Warning". - :vartype severity: str or ~api_management_client.models.Severity - :ivar type: The type of issue. Possible values include: "Unknown", "AgentStopped", - "GuestFirewall", "DnsResolution", "SocketBind", "NetworkSecurityRule", "UserDefinedRoute", - "PortThrottled", "Platform". - :vartype type: str or ~api_management_client.models.IssueType + :ivar origin: The origin of the issue. Known values are: "Local", "Inbound", "Outbound". + :vartype origin: str or ~azure.mgmt.apimanagement.models.Origin + :ivar severity: The severity of the issue. Known values are: "Error", "Warning". + :vartype severity: str or ~azure.mgmt.apimanagement.models.Severity + :ivar type: The type of issue. Known values are: "Unknown", "AgentStopped", "GuestFirewall", + "DnsResolution", "SocketBind", "NetworkSecurityRule", "UserDefinedRoute", "PortThrottled", + "Platform". + :vartype type: str or ~azure.mgmt.apimanagement.models.IssueType :ivar context: Provides additional context on the issue. :vartype context: list[dict[str, str]] """ @@ -7837,9 +8384,9 @@ class ConnectivityStatusContract(msrest.serialization.Model): :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: + :ivar status: Required. Resource Connectivity Status Type identifier. Known values are: "initializing", "success", "failure". - :vartype status: str or ~api_management_client.models.ConnectivityStatusType + :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. @@ -7881,7 +8428,7 @@ def __init__( self, *, name: str, - status: Union[str, "ConnectivityStatusType"], + status: Union[str, "_models.ConnectivityStatusType"], last_updated: datetime.datetime, last_status_change: datetime.datetime, resource_type: str, @@ -7893,9 +8440,9 @@ def __init__( :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 ~api_management_client.models.ConnectivityStatusType + :keyword status: Required. Resource Connectivity Status Type identifier. Known values are: + "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 @@ -7929,7 +8476,7 @@ class ContentItemCollection(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Collection of content items. - :vartype value: list[~api_management_client.models.ContentItemContract] + :vartype value: list[~azure.mgmt.apimanagement.models.ContentItemContract] :ivar next_link: Next page link, if any. :vartype next_link: str """ @@ -8005,7 +8552,7 @@ class ContentTypeCollection(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Collection of content types. - :vartype value: list[~api_management_client.models.ContentTypeContract] + :vartype value: list[~azure.mgmt.apimanagement.models.ContentTypeContract] :ivar next_link: Next page link, if any. :vartype next_link: str """ @@ -8107,9 +8654,9 @@ class DataMasking(msrest.serialization.Model): """DataMasking. :ivar query_params: Masking settings for Url query parameters. - :vartype query_params: list[~api_management_client.models.DataMaskingEntity] + :vartype query_params: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] :ivar headers: Masking settings for headers. - :vartype headers: list[~api_management_client.models.DataMaskingEntity] + :vartype headers: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] """ _attribute_map = { @@ -8120,15 +8667,15 @@ class DataMasking(msrest.serialization.Model): def __init__( self, *, - query_params: Optional[List["DataMaskingEntity"]] = None, - headers: Optional[List["DataMaskingEntity"]] = None, + query_params: Optional[List["_models.DataMaskingEntity"]] = None, + headers: Optional[List["_models.DataMaskingEntity"]] = None, **kwargs ): """ :keyword query_params: Masking settings for Url query parameters. - :paramtype query_params: list[~api_management_client.models.DataMaskingEntity] + :paramtype query_params: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] :keyword headers: Masking settings for headers. - :paramtype headers: list[~api_management_client.models.DataMaskingEntity] + :paramtype headers: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] """ super(DataMasking, self).__init__(**kwargs) self.query_params = query_params @@ -8140,8 +8687,8 @@ class DataMaskingEntity(msrest.serialization.Model): :ivar value: The name of an entity to mask (e.g. a name of a header or a query parameter). :vartype value: str - :ivar mode: Data masking mode. Possible values include: "Mask", "Hide". - :vartype mode: str or ~api_management_client.models.DataMaskingMode + :ivar mode: Data masking mode. Known values are: "Mask", "Hide". + :vartype mode: str or ~azure.mgmt.apimanagement.models.DataMaskingMode """ _attribute_map = { @@ -8153,14 +8700,14 @@ def __init__( self, *, value: Optional[str] = None, - mode: Optional[Union[str, "DataMaskingMode"]] = None, + mode: Optional[Union[str, "_models.DataMaskingMode"]] = None, **kwargs ): """ :keyword value: The name of an entity to mask (e.g. a name of a header or a query parameter). :paramtype value: str - :keyword mode: Data masking mode. Possible values include: "Mask", "Hide". - :paramtype mode: str or ~api_management_client.models.DataMaskingMode + :keyword mode: Data masking mode. Known values are: "Mask", "Hide". + :paramtype mode: str or ~azure.mgmt.apimanagement.models.DataMaskingMode """ super(DataMaskingEntity, self).__init__(**kwargs) self.value = value @@ -8242,7 +8789,7 @@ class DeletedServicesCollection(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Page values. - :vartype value: list[~api_management_client.models.DeletedServiceContract] + :vartype value: list[~azure.mgmt.apimanagement.models.DeletedServiceContract] :ivar next_link: Next page link if any. :vartype next_link: str """ @@ -8308,7 +8855,7 @@ class DiagnosticCollection(msrest.serialization.Model): """Paged Diagnostic list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.DiagnosticContract] + :vartype value: list[~azure.mgmt.apimanagement.models.DiagnosticContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -8324,14 +8871,14 @@ class DiagnosticCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["DiagnosticContract"]] = None, + value: Optional[List["_models.DiagnosticContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.DiagnosticContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.DiagnosticContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -8356,29 +8903,29 @@ class DiagnosticContract(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar always_log: Specifies for what type of messages sampling settings should not apply. - Possible values include: "allErrors". - :vartype always_log: str or ~api_management_client.models.AlwaysLog + :ivar always_log: Specifies for what type of messages sampling settings should not apply. Known + values are: "allErrors". + :vartype always_log: str or ~azure.mgmt.apimanagement.models.AlwaysLog :ivar logger_id: Resource Id of a target logger. :vartype logger_id: str :ivar sampling: Sampling settings for Diagnostic. - :vartype sampling: ~api_management_client.models.SamplingSettings + :vartype sampling: ~azure.mgmt.apimanagement.models.SamplingSettings :ivar frontend: Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. - :vartype frontend: ~api_management_client.models.PipelineDiagnosticSettings + :vartype frontend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings :ivar backend: Diagnostic settings for incoming/outgoing HTTP messages to the Backend. - :vartype backend: ~api_management_client.models.PipelineDiagnosticSettings + :vartype backend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings :ivar log_client_ip: Log the ClientIP. Default is false. :vartype log_client_ip: bool :ivar http_correlation_protocol: Sets correlation protocol to use for Application Insights - diagnostics. Possible values include: "None", "Legacy", "W3C". + diagnostics. Known values are: "None", "Legacy", "W3C". :vartype http_correlation_protocol: str or - ~api_management_client.models.HttpCorrelationProtocol - :ivar verbosity: The verbosity level applied to traces emitted by trace policies. Possible - values include: "verbose", "information", "error". - :vartype verbosity: str or ~api_management_client.models.Verbosity + ~azure.mgmt.apimanagement.models.HttpCorrelationProtocol + :ivar verbosity: The verbosity level applied to traces emitted by trace policies. Known values + are: "verbose", "information", "error". + :vartype verbosity: str or ~azure.mgmt.apimanagement.models.Verbosity :ivar operation_name_format: The format of the Operation Name for Application Insights - telemetries. Default is Name. Possible values include: "Name", "Url". - :vartype operation_name_format: str or ~api_management_client.models.OperationNameFormat + telemetries. Default is Name. Known values are: "Name", "Url". + :vartype operation_name_format: str or ~azure.mgmt.apimanagement.models.OperationNameFormat """ _validation = { @@ -8405,41 +8952,41 @@ class DiagnosticContract(Resource): def __init__( self, *, - always_log: Optional[Union[str, "AlwaysLog"]] = None, + always_log: Optional[Union[str, "_models.AlwaysLog"]] = None, logger_id: Optional[str] = None, - sampling: Optional["SamplingSettings"] = None, - frontend: Optional["PipelineDiagnosticSettings"] = None, - backend: Optional["PipelineDiagnosticSettings"] = None, + sampling: Optional["_models.SamplingSettings"] = None, + frontend: Optional["_models.PipelineDiagnosticSettings"] = None, + backend: Optional["_models.PipelineDiagnosticSettings"] = None, log_client_ip: Optional[bool] = None, - http_correlation_protocol: Optional[Union[str, "HttpCorrelationProtocol"]] = None, - verbosity: Optional[Union[str, "Verbosity"]] = None, - operation_name_format: Optional[Union[str, "OperationNameFormat"]] = None, + http_correlation_protocol: Optional[Union[str, "_models.HttpCorrelationProtocol"]] = None, + verbosity: Optional[Union[str, "_models.Verbosity"]] = None, + operation_name_format: Optional[Union[str, "_models.OperationNameFormat"]] = None, **kwargs ): """ :keyword always_log: Specifies for what type of messages sampling settings should not apply. - Possible values include: "allErrors". - :paramtype always_log: str or ~api_management_client.models.AlwaysLog + Known values are: "allErrors". + :paramtype always_log: str or ~azure.mgmt.apimanagement.models.AlwaysLog :keyword logger_id: Resource Id of a target logger. :paramtype logger_id: str :keyword sampling: Sampling settings for Diagnostic. - :paramtype sampling: ~api_management_client.models.SamplingSettings + :paramtype sampling: ~azure.mgmt.apimanagement.models.SamplingSettings :keyword frontend: Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. - :paramtype frontend: ~api_management_client.models.PipelineDiagnosticSettings + :paramtype frontend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings :keyword backend: Diagnostic settings for incoming/outgoing HTTP messages to the Backend. - :paramtype backend: ~api_management_client.models.PipelineDiagnosticSettings + :paramtype backend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings :keyword log_client_ip: Log the ClientIP. Default is false. :paramtype log_client_ip: bool :keyword http_correlation_protocol: Sets correlation protocol to use for Application Insights - diagnostics. Possible values include: "None", "Legacy", "W3C". + diagnostics. Known values are: "None", "Legacy", "W3C". :paramtype http_correlation_protocol: str or - ~api_management_client.models.HttpCorrelationProtocol - :keyword verbosity: The verbosity level applied to traces emitted by trace policies. Possible - values include: "verbose", "information", "error". - :paramtype verbosity: str or ~api_management_client.models.Verbosity + ~azure.mgmt.apimanagement.models.HttpCorrelationProtocol + :keyword verbosity: The verbosity level applied to traces emitted by trace policies. Known + values are: "verbose", "information", "error". + :paramtype verbosity: str or ~azure.mgmt.apimanagement.models.Verbosity :keyword operation_name_format: The format of the Operation Name for Application Insights - telemetries. Default is Name. Possible values include: "Name", "Url". - :paramtype operation_name_format: str or ~api_management_client.models.OperationNameFormat + telemetries. Default is Name. Known values are: "Name", "Url". + :paramtype operation_name_format: str or ~azure.mgmt.apimanagement.models.OperationNameFormat """ super(DiagnosticContract, self).__init__(**kwargs) self.always_log = always_log @@ -8457,7 +9004,7 @@ class EmailTemplateCollection(msrest.serialization.Model): """Paged email template list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.EmailTemplateContract] + :vartype value: list[~azure.mgmt.apimanagement.models.EmailTemplateContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -8473,14 +9020,14 @@ class EmailTemplateCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["EmailTemplateContract"]] = None, + value: Optional[List["_models.EmailTemplateContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.EmailTemplateContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.EmailTemplateContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -8518,7 +9065,7 @@ class EmailTemplateContract(Resource): :vartype is_default: bool :ivar parameters: Email Template Parameter values. :vartype parameters: - list[~api_management_client.models.EmailTemplateParametersContractProperties] + list[~azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties] """ _validation = { @@ -8549,7 +9096,7 @@ def __init__( body: Optional[str] = None, title: Optional[str] = None, description: Optional[str] = None, - parameters: Optional[List["EmailTemplateParametersContractProperties"]] = None, + parameters: Optional[List["_models.EmailTemplateParametersContractProperties"]] = None, **kwargs ): """ @@ -8563,7 +9110,7 @@ def __init__( :paramtype description: str :keyword parameters: Email Template Parameter values. :paramtype parameters: - list[~api_management_client.models.EmailTemplateParametersContractProperties] + list[~azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties] """ super(EmailTemplateContract, self).__init__(**kwargs) self.subject = subject @@ -8632,7 +9179,7 @@ class EmailTemplateUpdateParameters(msrest.serialization.Model): :vartype body: str :ivar parameters: Email Template Parameter values. :vartype parameters: - list[~api_management_client.models.EmailTemplateParametersContractProperties] + list[~azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties] """ _validation = { @@ -8655,7 +9202,7 @@ def __init__( title: Optional[str] = None, description: Optional[str] = None, body: Optional[str] = None, - parameters: Optional[List["EmailTemplateParametersContractProperties"]] = None, + parameters: Optional[List["_models.EmailTemplateParametersContractProperties"]] = None, **kwargs ): """ @@ -8669,7 +9216,7 @@ def __init__( :paramtype body: str :keyword parameters: Email Template Parameter values. :paramtype parameters: - list[~api_management_client.models.EmailTemplateParametersContractProperties] + list[~azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties] """ super(EmailTemplateUpdateParameters, self).__init__(**kwargs) self.subject = subject @@ -8685,7 +9232,7 @@ class EndpointDependency(msrest.serialization.Model): :ivar domain_name: The domain name of the dependency. :vartype domain_name: str :ivar endpoint_details: The Ports used when connecting to DomainName. - :vartype endpoint_details: list[~api_management_client.models.EndpointDetail] + :vartype endpoint_details: list[~azure.mgmt.apimanagement.models.EndpointDetail] """ _attribute_map = { @@ -8697,14 +9244,14 @@ def __init__( self, *, domain_name: Optional[str] = None, - endpoint_details: Optional[List["EndpointDetail"]] = None, + endpoint_details: Optional[List["_models.EndpointDetail"]] = None, **kwargs ): """ :keyword domain_name: The domain name of the dependency. :paramtype domain_name: str :keyword endpoint_details: The Ports used when connecting to DomainName. - :paramtype endpoint_details: list[~api_management_client.models.EndpointDetail] + :paramtype endpoint_details: list[~azure.mgmt.apimanagement.models.EndpointDetail] """ super(EndpointDependency, self).__init__(**kwargs) self.domain_name = domain_name @@ -8791,7 +9338,7 @@ class ErrorResponse(msrest.serialization.Model): :ivar message: Human-readable representation of the error. :vartype message: str :ivar details: The list of invalid fields send in request, in case of validation error. - :vartype details: list[~api_management_client.models.ErrorFieldContract] + :vartype details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] """ _attribute_map = { @@ -8805,7 +9352,7 @@ def __init__( *, code: Optional[str] = None, message: Optional[str] = None, - details: Optional[List["ErrorFieldContract"]] = None, + details: Optional[List["_models.ErrorFieldContract"]] = None, **kwargs ): """ @@ -8815,7 +9362,7 @@ def __init__( :keyword message: Human-readable representation of the error. :paramtype message: str :keyword details: The list of invalid fields send in request, in case of validation error. - :paramtype details: list[~api_management_client.models.ErrorFieldContract] + :paramtype details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] """ super(ErrorResponse, self).__init__(**kwargs) self.code = code @@ -8832,7 +9379,7 @@ class ErrorResponseBody(msrest.serialization.Model): :ivar message: Human-readable representation of the error. :vartype message: str :ivar details: The list of invalid fields send in request, in case of validation error. - :vartype details: list[~api_management_client.models.ErrorFieldContract] + :vartype details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] """ _attribute_map = { @@ -8846,7 +9393,7 @@ def __init__( *, code: Optional[str] = None, message: Optional[str] = None, - details: Optional[List["ErrorFieldContract"]] = None, + details: Optional[List["_models.ErrorFieldContract"]] = None, **kwargs ): """ @@ -8856,7 +9403,7 @@ def __init__( :keyword message: Human-readable representation of the error. :paramtype message: str :keyword details: The list of invalid fields send in request, in case of validation error. - :paramtype details: list[~api_management_client.models.ErrorFieldContract] + :paramtype details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] """ super(ErrorResponseBody, self).__init__(**kwargs) self.code = code @@ -8870,7 +9417,7 @@ class GatewayCertificateAuthorityCollection(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Page values. - :vartype value: list[~api_management_client.models.GatewayCertificateAuthorityContract] + :vartype value: list[~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract] :ivar next_link: Next page link if any. :vartype next_link: str """ @@ -8946,7 +9493,7 @@ class GatewayCollection(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Page values. - :vartype value: list[~api_management_client.models.GatewayContract] + :vartype value: list[~azure.mgmt.apimanagement.models.GatewayContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -8994,7 +9541,7 @@ class GatewayContract(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar location_data: Gateway location. - :vartype location_data: ~api_management_client.models.ResourceLocationDataContract + :vartype location_data: ~azure.mgmt.apimanagement.models.ResourceLocationDataContract :ivar description: Gateway description. :vartype description: str """ @@ -9017,13 +9564,13 @@ class GatewayContract(Resource): def __init__( self, *, - location_data: Optional["ResourceLocationDataContract"] = None, + location_data: Optional["_models.ResourceLocationDataContract"] = None, description: Optional[str] = None, **kwargs ): """ :keyword location_data: Gateway location. - :paramtype location_data: ~api_management_client.models.ResourceLocationDataContract + :paramtype location_data: ~azure.mgmt.apimanagement.models.ResourceLocationDataContract :keyword description: Gateway description. :paramtype description: str """ @@ -9038,7 +9585,7 @@ class GatewayHostnameConfigurationCollection(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Page values. - :vartype value: list[~api_management_client.models.GatewayHostnameConfigurationContract] + :vartype value: list[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract] :ivar next_link: Next page link if any. :vartype next_link: str """ @@ -9150,9 +9697,8 @@ class GatewayKeyRegenerationRequestContract(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar key_type: Required. The Key being regenerated. Possible values include: "primary", - "secondary". - :vartype key_type: str or ~api_management_client.models.KeyType + :ivar key_type: Required. The Key being regenerated. Known values are: "primary", "secondary". + :vartype key_type: str or ~azure.mgmt.apimanagement.models.KeyType """ _validation = { @@ -9166,13 +9712,13 @@ class GatewayKeyRegenerationRequestContract(msrest.serialization.Model): def __init__( self, *, - key_type: Union[str, "KeyType"], + key_type: Union[str, "_models.KeyType"], **kwargs ): """ - :keyword key_type: Required. The Key being regenerated. Possible values include: "primary", + :keyword key_type: Required. The Key being regenerated. Known values are: "primary", "secondary". - :paramtype key_type: str or ~api_management_client.models.KeyType + :paramtype key_type: str or ~azure.mgmt.apimanagement.models.KeyType """ super(GatewayKeyRegenerationRequestContract, self).__init__(**kwargs) self.key_type = key_type @@ -9240,9 +9786,9 @@ class GatewayTokenRequestContract(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar key_type: Required. The Key to be used to generate gateway token. Possible values - include: "primary", "secondary". - :vartype key_type: str or ~api_management_client.models.KeyType + :ivar key_type: Required. The Key to be used to generate gateway token. Known values are: + "primary", "secondary". + :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. @@ -9262,14 +9808,14 @@ class GatewayTokenRequestContract(msrest.serialization.Model): def __init__( self, *, - key_type: Union[str, "KeyType"], + key_type: Union[str, "_models.KeyType"], expiry: datetime.datetime, **kwargs ): """ - :keyword key_type: Required. The Key to be used to generate gateway token. Possible values - include: "primary", "secondary". - :paramtype key_type: str or ~api_management_client.models.KeyType + :keyword key_type: Required. The Key to be used to generate gateway token. Known values are: + "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. @@ -9311,7 +9857,7 @@ class GlobalSchemaCollection(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Global Schema Contract value. - :vartype value: list[~api_management_client.models.GlobalSchemaContract] + :vartype value: list[~azure.mgmt.apimanagement.models.GlobalSchemaContract] :ivar count: Total record count number. :vartype count: long :ivar next_link: Next page link if any. @@ -9358,8 +9904,8 @@ class GlobalSchemaContract(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar schema_type: Schema Type. Immutable. Possible values include: "xml", "json". - :vartype schema_type: str or ~api_management_client.models.SchemaType + :ivar schema_type: Schema Type. Immutable. Known values are: "xml", "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. @@ -9387,15 +9933,15 @@ class GlobalSchemaContract(Resource): def __init__( self, *, - schema_type: Optional[Union[str, "SchemaType"]] = None, + schema_type: Optional[Union[str, "_models.SchemaType"]] = None, description: Optional[str] = None, value: Optional[Any] = None, document: Optional[Any] = None, **kwargs ): """ - :keyword schema_type: Schema Type. Immutable. Possible values include: "xml", "json". - :paramtype schema_type: str or ~api_management_client.models.SchemaType + :keyword schema_type: Schema Type. Immutable. Known values are: "xml", "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. @@ -9415,7 +9961,7 @@ class GroupCollection(msrest.serialization.Model): """Paged Group list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.GroupContract] + :vartype value: list[~azure.mgmt.apimanagement.models.GroupContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -9431,14 +9977,14 @@ class GroupCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["GroupContract"]] = None, + value: Optional[List["_models.GroupContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.GroupContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.GroupContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -9470,9 +10016,8 @@ class GroupContract(Resource): :ivar built_in: true if the group is one of the three system groups (Administrators, Developers, or Guests); otherwise false. :vartype built_in: bool - :ivar type_properties_type: Group type. Possible values include: "custom", "system", - "external". - :vartype type_properties_type: str or ~api_management_client.models.GroupType + :ivar type_properties_type: Group type. Known values are: "custom", "system", "external". + :vartype type_properties_type: str or ~azure.mgmt.apimanagement.models.GroupType :ivar external_id: For external groups, this property contains the id of the group from the external identity provider, e.g. for Azure Active Directory ``aad://.onmicrosoft.com/groups/``\ ; otherwise the value is null. @@ -9504,7 +10049,7 @@ def __init__( *, display_name: Optional[str] = None, description: Optional[str] = None, - type_properties_type: Optional[Union[str, "GroupType"]] = None, + type_properties_type: Optional[Union[str, "_models.GroupType"]] = None, external_id: Optional[str] = None, **kwargs ): @@ -9513,9 +10058,8 @@ def __init__( :paramtype display_name: str :keyword description: Group description. Can contain HTML formatting tags. :paramtype description: str - :keyword type_properties_type: Group type. Possible values include: "custom", "system", - "external". - :paramtype type_properties_type: str or ~api_management_client.models.GroupType + :keyword type_properties_type: Group type. Known values are: "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. @@ -9543,8 +10087,8 @@ class GroupContractProperties(msrest.serialization.Model): :ivar built_in: true if the group is one of the three system groups (Administrators, Developers, or Guests); otherwise false. :vartype built_in: bool - :ivar type: Group type. Possible values include: "custom", "system", "external". - :vartype type: str or ~api_management_client.models.GroupType + :ivar type: Group type. Known values are: "custom", "system", "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. @@ -9570,7 +10114,7 @@ def __init__( *, display_name: str, description: Optional[str] = None, - type: Optional[Union[str, "GroupType"]] = None, + type: Optional[Union[str, "_models.GroupType"]] = None, external_id: Optional[str] = None, **kwargs ): @@ -9579,8 +10123,8 @@ def __init__( :paramtype display_name: str :keyword description: Group description. Can contain HTML formatting tags. :paramtype description: str - :keyword type: Group type. Possible values include: "custom", "system", "external". - :paramtype type: str or ~api_management_client.models.GroupType + :keyword type: Group type. Known values are: "custom", "system", "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. @@ -9601,8 +10145,8 @@ class GroupCreateParameters(msrest.serialization.Model): :vartype display_name: str :ivar description: Group description. :vartype description: str - :ivar type: Group type. Possible values include: "custom", "system", "external". - :vartype type: str or ~api_management_client.models.GroupType + :ivar type: Group type. Known values are: "custom", "system", "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. @@ -9625,7 +10169,7 @@ def __init__( *, display_name: Optional[str] = None, description: Optional[str] = None, - type: Optional[Union[str, "GroupType"]] = None, + type: Optional[Union[str, "_models.GroupType"]] = None, external_id: Optional[str] = None, **kwargs ): @@ -9634,8 +10178,8 @@ def __init__( :paramtype display_name: str :keyword description: Group description. :paramtype description: str - :keyword type: Group type. Possible values include: "custom", "system", "external". - :paramtype type: str or ~api_management_client.models.GroupType + :keyword type: Group type. Known values are: "custom", "system", "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. @@ -9655,8 +10199,8 @@ class GroupUpdateParameters(msrest.serialization.Model): :vartype display_name: str :ivar description: Group description. :vartype description: str - :ivar type: Group type. Possible values include: "custom", "system", "external". - :vartype type: str or ~api_management_client.models.GroupType + :ivar type: Group type. Known values are: "custom", "system", "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. @@ -9679,7 +10223,7 @@ def __init__( *, display_name: Optional[str] = None, description: Optional[str] = None, - type: Optional[Union[str, "GroupType"]] = None, + type: Optional[Union[str, "_models.GroupType"]] = None, external_id: Optional[str] = None, **kwargs ): @@ -9688,8 +10232,8 @@ def __init__( :paramtype display_name: str :keyword description: Group description. :paramtype description: str - :keyword type: Group type. Possible values include: "custom", "system", "external". - :paramtype type: str or ~api_management_client.models.GroupType + :keyword type: Group type. Known values are: "custom", "system", "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. @@ -9707,9 +10251,9 @@ class HostnameConfiguration(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Hostname type. Possible values include: "Proxy", "Portal", "Management", - "Scm", "DeveloperPortal". - :vartype type: str or ~api_management_client.models.HostnameType + :ivar type: Required. Hostname type. Known values are: "Proxy", "Portal", "Management", "Scm", + "DeveloperPortal". + :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 @@ -9734,13 +10278,13 @@ class HostnameConfiguration(msrest.serialization.Model): hostname. Default Value is false. :vartype negotiate_client_certificate: bool :ivar certificate: Certificate information. - :vartype certificate: ~api_management_client.models.CertificateInformation - :ivar certificate_source: Certificate Source. Possible values include: "Managed", "KeyVault", + :vartype certificate: ~azure.mgmt.apimanagement.models.CertificateInformation + :ivar certificate_source: Certificate Source. Known values are: "Managed", "KeyVault", "Custom", "BuiltIn". - :vartype certificate_source: str or ~api_management_client.models.CertificateSource - :ivar certificate_status: Certificate Status. Possible values include: "Completed", "Failed", + :vartype certificate_source: str or ~azure.mgmt.apimanagement.models.CertificateSource + :ivar certificate_status: Certificate Status. Known values are: "Completed", "Failed", "InProgress". - :vartype certificate_status: str or ~api_management_client.models.CertificateStatus + :vartype certificate_status: str or ~azure.mgmt.apimanagement.models.CertificateStatus """ _validation = { @@ -9765,7 +10309,7 @@ class HostnameConfiguration(msrest.serialization.Model): def __init__( self, *, - type: Union[str, "HostnameType"], + type: Union[str, "_models.HostnameType"], host_name: str, key_vault_id: Optional[str] = None, identity_client_id: Optional[str] = None, @@ -9773,15 +10317,15 @@ def __init__( certificate_password: Optional[str] = None, default_ssl_binding: Optional[bool] = False, negotiate_client_certificate: Optional[bool] = False, - certificate: Optional["CertificateInformation"] = None, - certificate_source: Optional[Union[str, "CertificateSource"]] = None, - certificate_status: Optional[Union[str, "CertificateStatus"]] = None, + certificate: Optional["_models.CertificateInformation"] = None, + certificate_source: Optional[Union[str, "_models.CertificateSource"]] = None, + certificate_status: Optional[Union[str, "_models.CertificateStatus"]] = None, **kwargs ): """ - :keyword type: Required. Hostname type. Possible values include: "Proxy", "Portal", - "Management", "Scm", "DeveloperPortal". - :paramtype type: str or ~api_management_client.models.HostnameType + :keyword type: Required. Hostname type. Known values are: "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 @@ -9806,13 +10350,13 @@ def __init__( the hostname. Default Value is false. :paramtype negotiate_client_certificate: bool :keyword certificate: Certificate information. - :paramtype certificate: ~api_management_client.models.CertificateInformation - :keyword certificate_source: Certificate Source. Possible values include: "Managed", - "KeyVault", "Custom", "BuiltIn". - :paramtype certificate_source: str or ~api_management_client.models.CertificateSource - :keyword certificate_status: Certificate Status. Possible values include: "Completed", - "Failed", "InProgress". - :paramtype certificate_status: str or ~api_management_client.models.CertificateStatus + :paramtype certificate: ~azure.mgmt.apimanagement.models.CertificateInformation + :keyword certificate_source: Certificate Source. Known values are: "Managed", "KeyVault", + "Custom", "BuiltIn". + :paramtype certificate_source: str or ~azure.mgmt.apimanagement.models.CertificateSource + :keyword certificate_status: Certificate Status. Known values are: "Completed", "Failed", + "InProgress". + :paramtype certificate_status: str or ~azure.mgmt.apimanagement.models.CertificateStatus """ super(HostnameConfiguration, self).__init__(**kwargs) self.type = type @@ -9873,9 +10417,9 @@ class HttpMessageDiagnostic(msrest.serialization.Model): :ivar headers: Array of HTTP Headers to log. :vartype headers: list[str] :ivar body: Body logging settings. - :vartype body: ~api_management_client.models.BodyDiagnosticSettings + :vartype body: ~azure.mgmt.apimanagement.models.BodyDiagnosticSettings :ivar data_masking: Data masking settings. - :vartype data_masking: ~api_management_client.models.DataMasking + :vartype data_masking: ~azure.mgmt.apimanagement.models.DataMasking """ _attribute_map = { @@ -9888,17 +10432,17 @@ def __init__( self, *, headers: Optional[List[str]] = None, - body: Optional["BodyDiagnosticSettings"] = None, - data_masking: Optional["DataMasking"] = None, + body: Optional["_models.BodyDiagnosticSettings"] = None, + data_masking: Optional["_models.DataMasking"] = None, **kwargs ): """ :keyword headers: Array of HTTP Headers to log. :paramtype headers: list[str] :keyword body: Body logging settings. - :paramtype body: ~api_management_client.models.BodyDiagnosticSettings + :paramtype body: ~azure.mgmt.apimanagement.models.BodyDiagnosticSettings :keyword data_masking: Data masking settings. - :paramtype data_masking: ~api_management_client.models.DataMasking + :paramtype data_masking: ~azure.mgmt.apimanagement.models.DataMasking """ super(HttpMessageDiagnostic, self).__init__(**kwargs) self.headers = headers @@ -9909,9 +10453,9 @@ def __init__( class IdentityProviderBaseParameters(msrest.serialization.Model): """Identity Provider Base Parameter Properties. - :ivar type: Identity Provider Type identifier. Possible values include: "facebook", "google", + :ivar type: Identity Provider Type identifier. Known values are: "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :vartype type: str or ~api_management_client.models.IdentityProviderType + :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. @@ -9928,6 +10472,9 @@ class IdentityProviderBaseParameters(msrest.serialization.Model): :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. :vartype password_reset_policy_name: str + :ivar client_library: The client library to be used in the developer portal. Only applies to + AAD and AAD B2C Identity Provider. + :vartype client_library: str """ _validation = { @@ -9936,6 +10483,7 @@ class IdentityProviderBaseParameters(msrest.serialization.Model): 'signin_policy_name': {'min_length': 1}, 'profile_editing_policy_name': {'min_length': 1}, 'password_reset_policy_name': {'min_length': 1}, + 'client_library': {'max_length': 16, 'min_length': 0}, } _attribute_map = { @@ -9947,12 +10495,13 @@ class IdentityProviderBaseParameters(msrest.serialization.Model): 'signin_policy_name': {'key': 'signinPolicyName', 'type': 'str'}, 'profile_editing_policy_name': {'key': 'profileEditingPolicyName', 'type': 'str'}, 'password_reset_policy_name': {'key': 'passwordResetPolicyName', 'type': 'str'}, + 'client_library': {'key': 'clientLibrary', 'type': 'str'}, } def __init__( self, *, - type: Optional[Union[str, "IdentityProviderType"]] = None, + type: Optional[Union[str, "_models.IdentityProviderType"]] = None, signin_tenant: Optional[str] = None, allowed_tenants: Optional[List[str]] = None, authority: Optional[str] = None, @@ -9960,12 +10509,13 @@ def __init__( signin_policy_name: Optional[str] = None, profile_editing_policy_name: Optional[str] = None, password_reset_policy_name: Optional[str] = None, + client_library: Optional[str] = None, **kwargs ): """ - :keyword type: Identity Provider Type identifier. Possible values include: "facebook", - "google", "microsoft", "twitter", "aad", "aadB2C". - :paramtype type: str or ~api_management_client.models.IdentityProviderType + :keyword type: Identity Provider Type identifier. Known values are: "facebook", "google", + "microsoft", "twitter", "aad", "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 @@ -9984,6 +10534,9 @@ def __init__( :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. :paramtype password_reset_policy_name: str + :keyword client_library: The client library to be used in the developer portal. Only applies to + AAD and AAD B2C Identity Provider. + :paramtype client_library: str """ super(IdentityProviderBaseParameters, self).__init__(**kwargs) self.type = type @@ -9994,6 +10547,7 @@ def __init__( self.signin_policy_name = signin_policy_name self.profile_editing_policy_name = profile_editing_policy_name self.password_reset_policy_name = password_reset_policy_name + self.client_library = client_library class IdentityProviderContract(Resource): @@ -10009,9 +10563,9 @@ class IdentityProviderContract(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar type_properties_type: Identity Provider Type identifier. Possible values include: - "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :vartype type_properties_type: str or ~api_management_client.models.IdentityProviderType + :ivar type_properties_type: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", "aadB2C". + :vartype type_properties_type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. :vartype signin_tenant: str :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. @@ -10028,6 +10582,9 @@ class IdentityProviderContract(Resource): :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. :vartype password_reset_policy_name: str + :ivar client_library: The client library to be used in the developer portal. Only applies to + AAD and AAD B2C Identity Provider. + :vartype client_library: str :ivar client_id: Client Id of the Application in the external Identity Provider. It is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. :vartype client_id: str @@ -10047,6 +10604,7 @@ class IdentityProviderContract(Resource): 'signin_policy_name': {'min_length': 1}, 'profile_editing_policy_name': {'min_length': 1}, 'password_reset_policy_name': {'min_length': 1}, + 'client_library': {'max_length': 16, 'min_length': 0}, 'client_id': {'min_length': 1}, 'client_secret': {'min_length': 1}, } @@ -10063,6 +10621,7 @@ class IdentityProviderContract(Resource): 'signin_policy_name': {'key': 'properties.signinPolicyName', 'type': 'str'}, 'profile_editing_policy_name': {'key': 'properties.profileEditingPolicyName', 'type': 'str'}, 'password_reset_policy_name': {'key': 'properties.passwordResetPolicyName', 'type': 'str'}, + 'client_library': {'key': 'properties.clientLibrary', 'type': 'str'}, 'client_id': {'key': 'properties.clientId', 'type': 'str'}, 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, } @@ -10070,7 +10629,7 @@ class IdentityProviderContract(Resource): def __init__( self, *, - type_properties_type: Optional[Union[str, "IdentityProviderType"]] = None, + type_properties_type: Optional[Union[str, "_models.IdentityProviderType"]] = None, signin_tenant: Optional[str] = None, allowed_tenants: Optional[List[str]] = None, authority: Optional[str] = None, @@ -10078,14 +10637,15 @@ def __init__( signin_policy_name: Optional[str] = None, profile_editing_policy_name: Optional[str] = None, password_reset_policy_name: Optional[str] = None, + client_library: Optional[str] = None, client_id: Optional[str] = None, client_secret: Optional[str] = None, **kwargs ): """ - :keyword type_properties_type: Identity Provider Type identifier. Possible values include: - "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :paramtype type_properties_type: str or ~api_management_client.models.IdentityProviderType + :keyword type_properties_type: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", "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 @@ -10104,6 +10664,9 @@ def __init__( :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. :paramtype password_reset_policy_name: str + :keyword client_library: The client library to be used in the developer portal. Only applies to + AAD and AAD B2C Identity Provider. + :paramtype client_library: str :keyword client_id: Client Id of the Application in the external Identity Provider. It is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. :paramtype client_id: str @@ -10122,6 +10685,7 @@ def __init__( self.signin_policy_name = signin_policy_name self.profile_editing_policy_name = profile_editing_policy_name self.password_reset_policy_name = password_reset_policy_name + self.client_library = client_library self.client_id = client_id self.client_secret = client_secret @@ -10131,9 +10695,9 @@ class IdentityProviderContractProperties(IdentityProviderBaseParameters): All required parameters must be populated in order to send to Azure. - :ivar type: Identity Provider Type identifier. Possible values include: "facebook", "google", + :ivar type: Identity Provider Type identifier. Known values are: "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :vartype type: str or ~api_management_client.models.IdentityProviderType + :vartype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. :vartype signin_tenant: str :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. @@ -10150,6 +10714,9 @@ class IdentityProviderContractProperties(IdentityProviderBaseParameters): :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. :vartype password_reset_policy_name: str + :ivar client_library: The client library to be used in the developer portal. Only applies to + AAD and AAD B2C Identity Provider. + :vartype client_library: str :ivar client_id: 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. :vartype client_id: str @@ -10166,6 +10733,7 @@ class IdentityProviderContractProperties(IdentityProviderBaseParameters): 'signin_policy_name': {'min_length': 1}, 'profile_editing_policy_name': {'min_length': 1}, 'password_reset_policy_name': {'min_length': 1}, + 'client_library': {'max_length': 16, 'min_length': 0}, 'client_id': {'required': True, 'min_length': 1}, 'client_secret': {'min_length': 1}, } @@ -10179,6 +10747,7 @@ class IdentityProviderContractProperties(IdentityProviderBaseParameters): 'signin_policy_name': {'key': 'signinPolicyName', 'type': 'str'}, 'profile_editing_policy_name': {'key': 'profileEditingPolicyName', 'type': 'str'}, 'password_reset_policy_name': {'key': 'passwordResetPolicyName', 'type': 'str'}, + 'client_library': {'key': 'clientLibrary', 'type': 'str'}, 'client_id': {'key': 'clientId', 'type': 'str'}, 'client_secret': {'key': 'clientSecret', 'type': 'str'}, } @@ -10187,7 +10756,7 @@ def __init__( self, *, client_id: str, - type: Optional[Union[str, "IdentityProviderType"]] = None, + type: Optional[Union[str, "_models.IdentityProviderType"]] = None, signin_tenant: Optional[str] = None, allowed_tenants: Optional[List[str]] = None, authority: Optional[str] = None, @@ -10195,13 +10764,14 @@ def __init__( signin_policy_name: Optional[str] = None, profile_editing_policy_name: Optional[str] = None, password_reset_policy_name: Optional[str] = None, + client_library: Optional[str] = None, client_secret: Optional[str] = None, **kwargs ): """ - :keyword type: Identity Provider Type identifier. Possible values include: "facebook", - "google", "microsoft", "twitter", "aad", "aadB2C". - :paramtype type: str or ~api_management_client.models.IdentityProviderType + :keyword type: Identity Provider Type identifier. Known values are: "facebook", "google", + "microsoft", "twitter", "aad", "aadB2C". + :paramtype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType :keyword signin_tenant: The TenantId to use instead of Common when logging into Active Directory. :paramtype signin_tenant: str @@ -10220,6 +10790,9 @@ def __init__( :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. :paramtype password_reset_policy_name: str + :keyword client_library: The client library to be used in the developer portal. Only applies to + AAD and AAD B2C Identity Provider. + :paramtype client_library: str :keyword client_id: 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 @@ -10229,7 +10802,7 @@ def __init__( Use '/listSecrets' POST request to get the value. :paramtype client_secret: str """ - super(IdentityProviderContractProperties, self).__init__(type=type, signin_tenant=signin_tenant, allowed_tenants=allowed_tenants, authority=authority, signup_policy_name=signup_policy_name, signin_policy_name=signin_policy_name, profile_editing_policy_name=profile_editing_policy_name, password_reset_policy_name=password_reset_policy_name, **kwargs) + super(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, client_library=client_library, **kwargs) self.client_id = client_id self.client_secret = client_secret @@ -10247,9 +10820,9 @@ class IdentityProviderCreateContract(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar type_properties_type: Identity Provider Type identifier. Possible values include: - "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :vartype type_properties_type: str or ~api_management_client.models.IdentityProviderType + :ivar type_properties_type: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", "aadB2C". + :vartype type_properties_type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. :vartype signin_tenant: str :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. @@ -10266,6 +10839,9 @@ class IdentityProviderCreateContract(Resource): :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. :vartype password_reset_policy_name: str + :ivar client_library: The client library to be used in the developer portal. Only applies to + AAD and AAD B2C Identity Provider. + :vartype client_library: str :ivar client_id: Client Id of the Application in the external Identity Provider. It is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. :vartype client_id: str @@ -10285,6 +10861,7 @@ class IdentityProviderCreateContract(Resource): 'signin_policy_name': {'min_length': 1}, 'profile_editing_policy_name': {'min_length': 1}, 'password_reset_policy_name': {'min_length': 1}, + 'client_library': {'max_length': 16, 'min_length': 0}, 'client_id': {'min_length': 1}, 'client_secret': {'min_length': 1}, } @@ -10301,6 +10878,7 @@ class IdentityProviderCreateContract(Resource): 'signin_policy_name': {'key': 'properties.signinPolicyName', 'type': 'str'}, 'profile_editing_policy_name': {'key': 'properties.profileEditingPolicyName', 'type': 'str'}, 'password_reset_policy_name': {'key': 'properties.passwordResetPolicyName', 'type': 'str'}, + 'client_library': {'key': 'properties.clientLibrary', 'type': 'str'}, 'client_id': {'key': 'properties.clientId', 'type': 'str'}, 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, } @@ -10308,7 +10886,7 @@ class IdentityProviderCreateContract(Resource): def __init__( self, *, - type_properties_type: Optional[Union[str, "IdentityProviderType"]] = None, + type_properties_type: Optional[Union[str, "_models.IdentityProviderType"]] = None, signin_tenant: Optional[str] = None, allowed_tenants: Optional[List[str]] = None, authority: Optional[str] = None, @@ -10316,14 +10894,15 @@ def __init__( signin_policy_name: Optional[str] = None, profile_editing_policy_name: Optional[str] = None, password_reset_policy_name: Optional[str] = None, + client_library: Optional[str] = None, client_id: Optional[str] = None, client_secret: Optional[str] = None, **kwargs ): """ - :keyword type_properties_type: Identity Provider Type identifier. Possible values include: - "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :paramtype type_properties_type: str or ~api_management_client.models.IdentityProviderType + :keyword type_properties_type: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", "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 @@ -10342,6 +10921,9 @@ def __init__( :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. :paramtype password_reset_policy_name: str + :keyword client_library: The client library to be used in the developer portal. Only applies to + AAD and AAD B2C Identity Provider. + :paramtype client_library: str :keyword client_id: Client Id of the Application in the external Identity Provider. It is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. :paramtype client_id: str @@ -10360,6 +10942,7 @@ def __init__( self.signin_policy_name = signin_policy_name self.profile_editing_policy_name = profile_editing_policy_name self.password_reset_policy_name = password_reset_policy_name + self.client_library = client_library self.client_id = client_id self.client_secret = client_secret @@ -10369,9 +10952,9 @@ class IdentityProviderCreateContractProperties(IdentityProviderBaseParameters): All required parameters must be populated in order to send to Azure. - :ivar type: Identity Provider Type identifier. Possible values include: "facebook", "google", + :ivar type: Identity Provider Type identifier. Known values are: "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :vartype type: str or ~api_management_client.models.IdentityProviderType + :vartype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. :vartype signin_tenant: str :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. @@ -10388,6 +10971,9 @@ class IdentityProviderCreateContractProperties(IdentityProviderBaseParameters): :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. :vartype password_reset_policy_name: str + :ivar client_library: The client library to be used in the developer portal. Only applies to + AAD and AAD B2C Identity Provider. + :vartype client_library: str :ivar client_id: 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. :vartype client_id: str @@ -10404,6 +10990,7 @@ class IdentityProviderCreateContractProperties(IdentityProviderBaseParameters): 'signin_policy_name': {'min_length': 1}, 'profile_editing_policy_name': {'min_length': 1}, 'password_reset_policy_name': {'min_length': 1}, + 'client_library': {'max_length': 16, 'min_length': 0}, 'client_id': {'required': True, 'min_length': 1}, 'client_secret': {'required': True, 'min_length': 1}, } @@ -10417,6 +11004,7 @@ class IdentityProviderCreateContractProperties(IdentityProviderBaseParameters): 'signin_policy_name': {'key': 'signinPolicyName', 'type': 'str'}, 'profile_editing_policy_name': {'key': 'profileEditingPolicyName', 'type': 'str'}, 'password_reset_policy_name': {'key': 'passwordResetPolicyName', 'type': 'str'}, + 'client_library': {'key': 'clientLibrary', 'type': 'str'}, 'client_id': {'key': 'clientId', 'type': 'str'}, 'client_secret': {'key': 'clientSecret', 'type': 'str'}, } @@ -10426,7 +11014,7 @@ def __init__( *, client_id: str, client_secret: str, - type: Optional[Union[str, "IdentityProviderType"]] = None, + type: Optional[Union[str, "_models.IdentityProviderType"]] = None, signin_tenant: Optional[str] = None, allowed_tenants: Optional[List[str]] = None, authority: Optional[str] = None, @@ -10434,12 +11022,13 @@ def __init__( signin_policy_name: Optional[str] = None, profile_editing_policy_name: Optional[str] = None, password_reset_policy_name: Optional[str] = None, + client_library: Optional[str] = None, **kwargs ): """ - :keyword type: Identity Provider Type identifier. Possible values include: "facebook", - "google", "microsoft", "twitter", "aad", "aadB2C". - :paramtype type: str or ~api_management_client.models.IdentityProviderType + :keyword type: Identity Provider Type identifier. Known values are: "facebook", "google", + "microsoft", "twitter", "aad", "aadB2C". + :paramtype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType :keyword signin_tenant: The TenantId to use instead of Common when logging into Active Directory. :paramtype signin_tenant: str @@ -10458,6 +11047,9 @@ def __init__( :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. :paramtype password_reset_policy_name: str + :keyword client_library: The client library to be used in the developer portal. Only applies to + AAD and AAD B2C Identity Provider. + :paramtype client_library: str :keyword client_id: 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 @@ -10467,7 +11059,7 @@ def __init__( 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) + 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, client_library=client_library, **kwargs) self.client_id = client_id self.client_secret = client_secret @@ -10476,7 +11068,7 @@ class IdentityProviderList(msrest.serialization.Model): """List of all the Identity Providers configured on the service instance. :ivar value: Identity Provider configuration values. - :vartype value: list[~api_management_client.models.IdentityProviderContract] + :vartype value: list[~azure.mgmt.apimanagement.models.IdentityProviderContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -10492,14 +11084,14 @@ class IdentityProviderList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["IdentityProviderContract"]] = None, + value: Optional[List["_models.IdentityProviderContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Identity Provider configuration values. - :paramtype value: list[~api_management_client.models.IdentityProviderContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.IdentityProviderContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -10514,9 +11106,9 @@ def __init__( class IdentityProviderUpdateParameters(msrest.serialization.Model): """Parameters supplied to update Identity Provider. - :ivar type: Identity Provider Type identifier. Possible values include: "facebook", "google", + :ivar type: Identity Provider Type identifier. Known values are: "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :vartype type: str or ~api_management_client.models.IdentityProviderType + :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. @@ -10533,6 +11125,9 @@ class IdentityProviderUpdateParameters(msrest.serialization.Model): :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. :vartype password_reset_policy_name: str + :ivar client_library: The client library to be used in the developer portal. Only applies to + AAD and AAD B2C Identity Provider. + :vartype client_library: str :ivar client_id: Client Id of the Application in the external Identity Provider. It is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. :vartype client_id: str @@ -10548,6 +11143,7 @@ class IdentityProviderUpdateParameters(msrest.serialization.Model): 'signin_policy_name': {'min_length': 1}, 'profile_editing_policy_name': {'min_length': 1}, 'password_reset_policy_name': {'min_length': 1}, + 'client_library': {'max_length': 16, 'min_length': 0}, 'client_id': {'min_length': 1}, 'client_secret': {'min_length': 1}, } @@ -10561,6 +11157,7 @@ class IdentityProviderUpdateParameters(msrest.serialization.Model): 'signin_policy_name': {'key': 'properties.signinPolicyName', 'type': 'str'}, 'profile_editing_policy_name': {'key': 'properties.profileEditingPolicyName', 'type': 'str'}, 'password_reset_policy_name': {'key': 'properties.passwordResetPolicyName', 'type': 'str'}, + 'client_library': {'key': 'properties.clientLibrary', 'type': 'str'}, 'client_id': {'key': 'properties.clientId', 'type': 'str'}, 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, } @@ -10568,7 +11165,7 @@ class IdentityProviderUpdateParameters(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "IdentityProviderType"]] = None, + type: Optional[Union[str, "_models.IdentityProviderType"]] = None, signin_tenant: Optional[str] = None, allowed_tenants: Optional[List[str]] = None, authority: Optional[str] = None, @@ -10576,14 +11173,15 @@ def __init__( signin_policy_name: Optional[str] = None, profile_editing_policy_name: Optional[str] = None, password_reset_policy_name: Optional[str] = None, + client_library: Optional[str] = None, client_id: Optional[str] = None, client_secret: Optional[str] = None, **kwargs ): """ - :keyword type: Identity Provider Type identifier. Possible values include: "facebook", - "google", "microsoft", "twitter", "aad", "aadB2C". - :paramtype type: str or ~api_management_client.models.IdentityProviderType + :keyword type: Identity Provider Type identifier. Known values are: "facebook", "google", + "microsoft", "twitter", "aad", "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 @@ -10602,6 +11200,9 @@ def __init__( :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. :paramtype password_reset_policy_name: str + :keyword client_library: The client library to be used in the developer portal. Only applies to + AAD and AAD B2C Identity Provider. + :paramtype client_library: str :keyword client_id: Client Id of the Application in the external Identity Provider. It is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. :paramtype client_id: str @@ -10619,6 +11220,7 @@ def __init__( self.signin_policy_name = signin_policy_name self.profile_editing_policy_name = profile_editing_policy_name self.password_reset_policy_name = password_reset_policy_name + self.client_library = client_library self.client_id = client_id self.client_secret = client_secret @@ -10626,9 +11228,9 @@ def __init__( class IdentityProviderUpdateProperties(IdentityProviderBaseParameters): """Parameters supplied to the Update Identity Provider operation. - :ivar type: Identity Provider Type identifier. Possible values include: "facebook", "google", + :ivar type: Identity Provider Type identifier. Known values are: "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". - :vartype type: str or ~api_management_client.models.IdentityProviderType + :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. @@ -10645,6 +11247,9 @@ class IdentityProviderUpdateProperties(IdentityProviderBaseParameters): :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. :vartype password_reset_policy_name: str + :ivar client_library: The client library to be used in the developer portal. Only applies to + AAD and AAD B2C Identity Provider. + :vartype client_library: str :ivar client_id: Client Id of the Application in the external Identity Provider. It is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. :vartype client_id: str @@ -10660,6 +11265,7 @@ class IdentityProviderUpdateProperties(IdentityProviderBaseParameters): 'signin_policy_name': {'min_length': 1}, 'profile_editing_policy_name': {'min_length': 1}, 'password_reset_policy_name': {'min_length': 1}, + 'client_library': {'max_length': 16, 'min_length': 0}, 'client_id': {'min_length': 1}, 'client_secret': {'min_length': 1}, } @@ -10673,6 +11279,7 @@ class IdentityProviderUpdateProperties(IdentityProviderBaseParameters): 'signin_policy_name': {'key': 'signinPolicyName', 'type': 'str'}, 'profile_editing_policy_name': {'key': 'profileEditingPolicyName', 'type': 'str'}, 'password_reset_policy_name': {'key': 'passwordResetPolicyName', 'type': 'str'}, + 'client_library': {'key': 'clientLibrary', 'type': 'str'}, 'client_id': {'key': 'clientId', 'type': 'str'}, 'client_secret': {'key': 'clientSecret', 'type': 'str'}, } @@ -10680,7 +11287,7 @@ class IdentityProviderUpdateProperties(IdentityProviderBaseParameters): def __init__( self, *, - type: Optional[Union[str, "IdentityProviderType"]] = None, + type: Optional[Union[str, "_models.IdentityProviderType"]] = None, signin_tenant: Optional[str] = None, allowed_tenants: Optional[List[str]] = None, authority: Optional[str] = None, @@ -10688,14 +11295,15 @@ def __init__( signin_policy_name: Optional[str] = None, profile_editing_policy_name: Optional[str] = None, password_reset_policy_name: Optional[str] = None, + client_library: Optional[str] = None, client_id: Optional[str] = None, client_secret: Optional[str] = None, **kwargs ): """ - :keyword type: Identity Provider Type identifier. Possible values include: "facebook", - "google", "microsoft", "twitter", "aad", "aadB2C". - :paramtype type: str or ~api_management_client.models.IdentityProviderType + :keyword type: Identity Provider Type identifier. Known values are: "facebook", "google", + "microsoft", "twitter", "aad", "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 @@ -10714,6 +11322,9 @@ def __init__( :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity Provider. :paramtype password_reset_policy_name: str + :keyword client_library: The client library to be used in the developer portal. Only applies to + AAD and AAD B2C Identity Provider. + :paramtype client_library: str :keyword client_id: Client Id of the Application in the external Identity Provider. It is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. :paramtype client_id: str @@ -10722,7 +11333,7 @@ def __init__( Google login, Public Key for Microsoft. :paramtype client_secret: str """ - super(IdentityProviderUpdateProperties, self).__init__(type=type, signin_tenant=signin_tenant, allowed_tenants=allowed_tenants, authority=authority, signup_policy_name=signup_policy_name, signin_policy_name=signin_policy_name, profile_editing_policy_name=profile_editing_policy_name, password_reset_policy_name=password_reset_policy_name, **kwargs) + super(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, client_library=client_library, **kwargs) self.client_id = client_id self.client_secret = client_secret @@ -10733,7 +11344,7 @@ class IssueAttachmentCollection(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Issue Attachment values. - :vartype value: list[~api_management_client.models.IssueAttachmentContract] + :vartype value: list[~azure.mgmt.apimanagement.models.IssueAttachmentContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -10833,7 +11444,7 @@ class IssueCollection(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Issue values. - :vartype value: list[~api_management_client.models.IssueContract] + :vartype value: list[~azure.mgmt.apimanagement.models.IssueContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -10873,7 +11484,7 @@ class IssueCommentCollection(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Issue Comment values. - :vartype value: list[~api_management_client.models.IssueCommentContract] + :vartype value: list[~azure.mgmt.apimanagement.models.IssueCommentContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -10980,9 +11591,9 @@ class IssueContract(Resource): :vartype type: str :ivar created_date: Date and time when the issue was created. :vartype created_date: ~datetime.datetime - :ivar state: Status of the issue. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :vartype state: str or ~api_management_client.models.State + :ivar state: Status of the issue. Known values are: "proposed", "open", "removed", "resolved", + "closed". + :vartype state: str or ~azure.mgmt.apimanagement.models.State :ivar api_id: A resource identifier for the API the issue was created for. :vartype api_id: str :ivar title: The issue title. @@ -11015,7 +11626,7 @@ def __init__( self, *, created_date: Optional[datetime.datetime] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, api_id: Optional[str] = None, title: Optional[str] = None, description: Optional[str] = None, @@ -11025,9 +11636,9 @@ def __init__( """ :keyword created_date: Date and time when the issue was created. :paramtype created_date: ~datetime.datetime - :keyword state: Status of the issue. Possible values include: "proposed", "open", "removed", + :keyword state: Status of the issue. Known values are: "proposed", "open", "removed", "resolved", "closed". - :paramtype state: str or ~api_management_client.models.State + :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. @@ -11051,9 +11662,9 @@ class IssueContractBaseProperties(msrest.serialization.Model): :ivar created_date: Date and time when the issue was created. :vartype created_date: ~datetime.datetime - :ivar state: Status of the issue. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :vartype state: str or ~api_management_client.models.State + :ivar state: Status of the issue. Known values are: "proposed", "open", "removed", "resolved", + "closed". + :vartype state: str or ~azure.mgmt.apimanagement.models.State :ivar api_id: A resource identifier for the API the issue was created for. :vartype api_id: str """ @@ -11068,16 +11679,16 @@ def __init__( self, *, created_date: Optional[datetime.datetime] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, api_id: Optional[str] = None, **kwargs ): """ :keyword created_date: Date and time when the issue was created. :paramtype created_date: ~datetime.datetime - :keyword state: Status of the issue. Possible values include: "proposed", "open", "removed", + :keyword state: Status of the issue. Known values are: "proposed", "open", "removed", "resolved", "closed". - :paramtype state: str or ~api_management_client.models.State + :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 """ @@ -11094,9 +11705,9 @@ class IssueContractProperties(IssueContractBaseProperties): :ivar created_date: Date and time when the issue was created. :vartype created_date: ~datetime.datetime - :ivar state: Status of the issue. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :vartype state: str or ~api_management_client.models.State + :ivar state: Status of the issue. Known values are: "proposed", "open", "removed", "resolved", + "closed". + :vartype state: str or ~azure.mgmt.apimanagement.models.State :ivar api_id: A resource identifier for the API the issue was created for. :vartype api_id: str :ivar title: Required. The issue title. @@ -11129,16 +11740,16 @@ def __init__( description: str, user_id: str, created_date: Optional[datetime.datetime] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, api_id: Optional[str] = None, **kwargs ): """ :keyword created_date: Date and time when the issue was created. :paramtype created_date: ~datetime.datetime - :keyword state: Status of the issue. Possible values include: "proposed", "open", "removed", + :keyword state: Status of the issue. Known values are: "proposed", "open", "removed", "resolved", "closed". - :paramtype state: str or ~api_management_client.models.State + :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. @@ -11159,9 +11770,9 @@ class IssueUpdateContract(msrest.serialization.Model): :ivar created_date: Date and time when the issue was created. :vartype created_date: ~datetime.datetime - :ivar state: Status of the issue. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :vartype state: str or ~api_management_client.models.State + :ivar state: Status of the issue. Known values are: "proposed", "open", "removed", "resolved", + "closed". + :vartype state: str or ~azure.mgmt.apimanagement.models.State :ivar api_id: A resource identifier for the API the issue was created for. :vartype api_id: str :ivar title: The issue title. @@ -11185,7 +11796,7 @@ def __init__( self, *, created_date: Optional[datetime.datetime] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, api_id: Optional[str] = None, title: Optional[str] = None, description: Optional[str] = None, @@ -11195,9 +11806,9 @@ def __init__( """ :keyword created_date: Date and time when the issue was created. :paramtype created_date: ~datetime.datetime - :keyword state: Status of the issue. Possible values include: "proposed", "open", "removed", + :keyword state: Status of the issue. Known values are: "proposed", "open", "removed", "resolved", "closed". - :paramtype state: str or ~api_management_client.models.State + :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. @@ -11221,9 +11832,9 @@ class IssueUpdateContractProperties(IssueContractBaseProperties): :ivar created_date: Date and time when the issue was created. :vartype created_date: ~datetime.datetime - :ivar state: Status of the issue. Possible values include: "proposed", "open", "removed", - "resolved", "closed". - :vartype state: str or ~api_management_client.models.State + :ivar state: Status of the issue. Known values are: "proposed", "open", "removed", "resolved", + "closed". + :vartype state: str or ~azure.mgmt.apimanagement.models.State :ivar api_id: A resource identifier for the API the issue was created for. :vartype api_id: str :ivar title: The issue title. @@ -11247,7 +11858,7 @@ def __init__( self, *, created_date: Optional[datetime.datetime] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, api_id: Optional[str] = None, title: Optional[str] = None, description: Optional[str] = None, @@ -11257,9 +11868,9 @@ def __init__( """ :keyword created_date: Date and time when the issue was created. :paramtype created_date: ~datetime.datetime - :keyword state: Status of the issue. Possible values include: "proposed", "open", "removed", + :keyword state: Status of the issue. Known values are: "proposed", "open", "removed", "resolved", "closed". - :paramtype state: str or ~api_management_client.models.State + :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. @@ -11282,8 +11893,8 @@ class KeyVaultContractCreateProperties(msrest.serialization.Model): secret will prevent auto-refresh. This requires API Management service to be configured with aka.ms/apimmsi. :vartype secret_identifier: str - :ivar identity_client_id: SystemAssignedIdentity or UserAssignedIdentity Client Id which will - be used to access key vault secret. + :ivar identity_client_id: Null for SystemAssignedIdentity or Client Id for UserAssignedIdentity + , which will be used to access key vault secret. :vartype identity_client_id: str """ @@ -11304,8 +11915,8 @@ def __init__( versioned secret will prevent auto-refresh. This requires API Management service to be configured with aka.ms/apimmsi. :paramtype secret_identifier: str - :keyword identity_client_id: SystemAssignedIdentity or UserAssignedIdentity Client Id which - will be used to access key vault secret. + :keyword identity_client_id: Null for SystemAssignedIdentity or Client Id for + UserAssignedIdentity , which will be used to access key vault secret. :paramtype identity_client_id: str """ super(KeyVaultContractCreateProperties, self).__init__(**kwargs) @@ -11320,11 +11931,12 @@ class KeyVaultContractProperties(KeyVaultContractCreateProperties): secret will prevent auto-refresh. This requires API Management service to be configured with aka.ms/apimmsi. :vartype secret_identifier: str - :ivar identity_client_id: SystemAssignedIdentity or UserAssignedIdentity Client Id which will - be used to access key vault secret. + :ivar identity_client_id: Null for SystemAssignedIdentity or Client Id for UserAssignedIdentity + , which will be used to access key vault secret. :vartype identity_client_id: str :ivar last_status: Last time sync and refresh status of secret from key vault. - :vartype last_status: ~api_management_client.models.KeyVaultLastAccessStatusContractProperties + :vartype last_status: + ~azure.mgmt.apimanagement.models.KeyVaultLastAccessStatusContractProperties """ _attribute_map = { @@ -11338,7 +11950,7 @@ def __init__( *, secret_identifier: Optional[str] = None, identity_client_id: Optional[str] = None, - last_status: Optional["KeyVaultLastAccessStatusContractProperties"] = None, + last_status: Optional["_models.KeyVaultLastAccessStatusContractProperties"] = None, **kwargs ): """ @@ -11346,12 +11958,12 @@ def __init__( versioned secret will prevent auto-refresh. This requires API Management service to be configured with aka.ms/apimmsi. :paramtype secret_identifier: str - :keyword identity_client_id: SystemAssignedIdentity or UserAssignedIdentity Client Id which - will be used to access key vault secret. + :keyword identity_client_id: Null for SystemAssignedIdentity or Client Id for + UserAssignedIdentity , which will be used to access key vault secret. :paramtype identity_client_id: str :keyword last_status: Last time sync and refresh status of secret from key vault. :paramtype last_status: - ~api_management_client.models.KeyVaultLastAccessStatusContractProperties + ~azure.mgmt.apimanagement.models.KeyVaultLastAccessStatusContractProperties """ super(KeyVaultContractProperties, self).__init__(secret_identifier=secret_identifier, identity_client_id=identity_client_id, **kwargs) self.last_status = last_status @@ -11402,7 +12014,7 @@ class LoggerCollection(msrest.serialization.Model): """Paged Logger list representation. :ivar value: Logger values. - :vartype value: list[~api_management_client.models.LoggerContract] + :vartype value: list[~azure.mgmt.apimanagement.models.LoggerContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -11418,14 +12030,14 @@ class LoggerCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["LoggerContract"]] = None, + value: Optional[List["_models.LoggerContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Logger values. - :paramtype value: list[~api_management_client.models.LoggerContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.LoggerContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -11450,9 +12062,9 @@ class LoggerContract(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar logger_type: Logger type. Possible values include: "azureEventHub", - "applicationInsights", "azureMonitor". - :vartype logger_type: str or ~api_management_client.models.LoggerType + :ivar logger_type: Logger type. Known values are: "azureEventHub", "applicationInsights", + "azureMonitor". + :vartype logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType :ivar description: Logger description. :vartype description: str :ivar credentials: The name and SendRule connection string of the event hub for azureEventHub @@ -11488,7 +12100,7 @@ class LoggerContract(Resource): def __init__( self, *, - logger_type: Optional[Union[str, "LoggerType"]] = None, + logger_type: Optional[Union[str, "_models.LoggerType"]] = None, description: Optional[str] = None, credentials: Optional[Dict[str, str]] = None, is_buffered: Optional[bool] = None, @@ -11496,9 +12108,9 @@ def __init__( **kwargs ): """ - :keyword logger_type: Logger type. Possible values include: "azureEventHub", - "applicationInsights", "azureMonitor". - :paramtype logger_type: str or ~api_management_client.models.LoggerType + :keyword logger_type: Logger type. Known values are: "azureEventHub", "applicationInsights", + "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 @@ -11523,9 +12135,9 @@ def __init__( class LoggerUpdateContract(msrest.serialization.Model): """Logger update contract. - :ivar logger_type: Logger type. Possible values include: "azureEventHub", - "applicationInsights", "azureMonitor". - :vartype logger_type: str or ~api_management_client.models.LoggerType + :ivar logger_type: Logger type. Known values are: "azureEventHub", "applicationInsights", + "azureMonitor". + :vartype logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType :ivar description: Logger description. :vartype description: str :ivar credentials: Logger credentials. @@ -11545,16 +12157,16 @@ class LoggerUpdateContract(msrest.serialization.Model): def __init__( self, *, - logger_type: Optional[Union[str, "LoggerType"]] = None, + logger_type: Optional[Union[str, "_models.LoggerType"]] = None, description: Optional[str] = None, credentials: Optional[Dict[str, str]] = None, is_buffered: Optional[bool] = None, **kwargs ): """ - :keyword logger_type: Logger type. Possible values include: "azureEventHub", - "applicationInsights", "azureMonitor". - :paramtype logger_type: str or ~api_management_client.models.LoggerType + :keyword logger_type: Logger type. Known values are: "azureEventHub", "applicationInsights", + "azureMonitor". + :paramtype logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType :keyword description: Logger description. :paramtype description: str :keyword credentials: Logger credentials. @@ -11574,7 +12186,7 @@ class NamedValueCollection(msrest.serialization.Model): """Paged NamedValue list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.NamedValueContract] + :vartype value: list[~azure.mgmt.apimanagement.models.NamedValueContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -11590,14 +12202,14 @@ class NamedValueCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["NamedValueContract"]] = None, + value: Optional[List["_models.NamedValueContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.NamedValueContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.NamedValueContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -11636,7 +12248,7 @@ class NamedValueContract(Resource): '/listSecrets' POST request to get the value. :vartype value: str :ivar key_vault: KeyVault location details of the namedValue. - :vartype key_vault: ~api_management_client.models.KeyVaultContractProperties + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties """ _validation = { @@ -11666,7 +12278,7 @@ def __init__( secret: Optional[bool] = None, display_name: Optional[str] = None, value: Optional[str] = None, - key_vault: Optional["KeyVaultContractProperties"] = None, + key_vault: Optional["_models.KeyVaultContractProperties"] = None, **kwargs ): """ @@ -11684,7 +12296,7 @@ def __init__( '/listSecrets' POST request to get the value. :paramtype value: str :keyword key_vault: KeyVault location details of the namedValue. - :paramtype key_vault: ~api_management_client.models.KeyVaultContractProperties + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties """ super(NamedValueContract, self).__init__(**kwargs) self.tags = tags @@ -11753,7 +12365,7 @@ class NamedValueContractProperties(NamedValueEntityBaseParameters): '/listSecrets' POST request to get the value. :vartype value: str :ivar key_vault: KeyVault location details of the namedValue. - :vartype key_vault: ~api_management_client.models.KeyVaultContractProperties + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties """ _validation = { @@ -11777,7 +12389,7 @@ def __init__( tags: Optional[List[str]] = None, secret: Optional[bool] = None, value: Optional[str] = None, - key_vault: Optional["KeyVaultContractProperties"] = None, + key_vault: Optional["_models.KeyVaultContractProperties"] = None, **kwargs ): """ @@ -11795,7 +12407,7 @@ def __init__( '/listSecrets' POST request to get the value. :paramtype value: str :keyword key_vault: KeyVault location details of the namedValue. - :paramtype key_vault: ~api_management_client.models.KeyVaultContractProperties + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties """ super(NamedValueContractProperties, self).__init__(tags=tags, secret=secret, **kwargs) self.display_name = display_name @@ -11830,7 +12442,7 @@ class NamedValueCreateContract(Resource): '/listSecrets' POST request to get the value. :vartype value: str :ivar key_vault: KeyVault location details of the namedValue. - :vartype key_vault: ~api_management_client.models.KeyVaultContractCreateProperties + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ _validation = { @@ -11860,7 +12472,7 @@ def __init__( secret: Optional[bool] = None, display_name: Optional[str] = None, value: Optional[str] = None, - key_vault: Optional["KeyVaultContractCreateProperties"] = None, + key_vault: Optional["_models.KeyVaultContractCreateProperties"] = None, **kwargs ): """ @@ -11878,7 +12490,7 @@ def __init__( '/listSecrets' POST request to get the value. :paramtype value: str :keyword key_vault: KeyVault location details of the namedValue. - :paramtype key_vault: ~api_management_client.models.KeyVaultContractCreateProperties + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ super(NamedValueCreateContract, self).__init__(**kwargs) self.tags = tags @@ -11907,7 +12519,7 @@ class NamedValueCreateContractProperties(NamedValueEntityBaseParameters): '/listSecrets' POST request to get the value. :vartype value: str :ivar key_vault: KeyVault location details of the namedValue. - :vartype key_vault: ~api_management_client.models.KeyVaultContractCreateProperties + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ _validation = { @@ -11931,7 +12543,7 @@ def __init__( tags: Optional[List[str]] = None, secret: Optional[bool] = None, value: Optional[str] = None, - key_vault: Optional["KeyVaultContractCreateProperties"] = None, + key_vault: Optional["_models.KeyVaultContractCreateProperties"] = None, **kwargs ): """ @@ -11949,7 +12561,7 @@ def __init__( '/listSecrets' POST request to get the value. :paramtype value: str :keyword key_vault: KeyVault location details of the namedValue. - :paramtype key_vault: ~api_management_client.models.KeyVaultContractCreateProperties + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ super(NamedValueCreateContractProperties, self).__init__(tags=tags, secret=secret, **kwargs) self.display_name = display_name @@ -11998,7 +12610,7 @@ class NamedValueUpdateParameterProperties(NamedValueEntityBaseParameters): consist only of whitespace. :vartype value: str :ivar key_vault: KeyVault location details of the namedValue. - :vartype key_vault: ~api_management_client.models.KeyVaultContractCreateProperties + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ _validation = { @@ -12022,7 +12634,7 @@ def __init__( secret: Optional[bool] = None, display_name: Optional[str] = None, value: Optional[str] = None, - key_vault: Optional["KeyVaultContractCreateProperties"] = None, + key_vault: Optional["_models.KeyVaultContractCreateProperties"] = None, **kwargs ): """ @@ -12039,7 +12651,7 @@ def __init__( consist only of whitespace. :paramtype value: str :keyword key_vault: KeyVault location details of the namedValue. - :paramtype key_vault: ~api_management_client.models.KeyVaultContractCreateProperties + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ super(NamedValueUpdateParameterProperties, self).__init__(tags=tags, secret=secret, **kwargs) self.display_name = display_name @@ -12063,7 +12675,7 @@ class NamedValueUpdateParameters(msrest.serialization.Model): consist only of whitespace. :vartype value: str :ivar key_vault: KeyVault location details of the namedValue. - :vartype key_vault: ~api_management_client.models.KeyVaultContractCreateProperties + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ _validation = { @@ -12087,7 +12699,7 @@ def __init__( secret: Optional[bool] = None, display_name: Optional[str] = None, value: Optional[str] = None, - key_vault: Optional["KeyVaultContractCreateProperties"] = None, + key_vault: Optional["_models.KeyVaultContractCreateProperties"] = None, **kwargs ): """ @@ -12104,7 +12716,7 @@ def __init__( consist only of whitespace. :paramtype value: str :keyword key_vault: KeyVault location details of the namedValue. - :paramtype key_vault: ~api_management_client.models.KeyVaultContractCreateProperties + :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ super(NamedValueUpdateParameters, self).__init__(**kwargs) self.tags = tags @@ -12123,7 +12735,7 @@ class NetworkStatusContract(msrest.serialization.Model): :vartype dns_servers: list[str] :ivar connectivity_status: Required. Gets the list of Connectivity Status to the Resources on which the service depends upon. - :vartype connectivity_status: list[~api_management_client.models.ConnectivityStatusContract] + :vartype connectivity_status: list[~azure.mgmt.apimanagement.models.ConnectivityStatusContract] """ _validation = { @@ -12140,7 +12752,7 @@ def __init__( self, *, dns_servers: List[str], - connectivity_status: List["ConnectivityStatusContract"], + connectivity_status: List["_models.ConnectivityStatusContract"], **kwargs ): """ @@ -12148,7 +12760,8 @@ def __init__( :paramtype dns_servers: list[str] :keyword connectivity_status: Required. Gets the list of Connectivity Status to the Resources on which the service depends upon. - :paramtype connectivity_status: list[~api_management_client.models.ConnectivityStatusContract] + :paramtype connectivity_status: + list[~azure.mgmt.apimanagement.models.ConnectivityStatusContract] """ super(NetworkStatusContract, self).__init__(**kwargs) self.dns_servers = dns_servers @@ -12161,7 +12774,7 @@ class NetworkStatusContractByLocation(msrest.serialization.Model): :ivar location: Location of service. :vartype location: str :ivar network_status: Network status in Location. - :vartype network_status: ~api_management_client.models.NetworkStatusContract + :vartype network_status: ~azure.mgmt.apimanagement.models.NetworkStatusContract """ _validation = { @@ -12177,14 +12790,14 @@ def __init__( self, *, location: Optional[str] = None, - network_status: Optional["NetworkStatusContract"] = None, + network_status: Optional["_models.NetworkStatusContract"] = None, **kwargs ): """ :keyword location: Location of service. :paramtype location: str :keyword network_status: Network status in Location. - :paramtype network_status: ~api_management_client.models.NetworkStatusContract + :paramtype network_status: ~azure.mgmt.apimanagement.models.NetworkStatusContract """ super(NetworkStatusContractByLocation, self).__init__(**kwargs) self.location = location @@ -12195,7 +12808,7 @@ class NotificationCollection(msrest.serialization.Model): """Paged Notification list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.NotificationContract] + :vartype value: list[~azure.mgmt.apimanagement.models.NotificationContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -12211,14 +12824,14 @@ class NotificationCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["NotificationContract"]] = None, + value: Optional[List["_models.NotificationContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.NotificationContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.NotificationContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -12248,7 +12861,7 @@ class NotificationContract(Resource): :ivar description: Description of the Notification. :vartype description: str :ivar recipients: Recipient Parameter values. - :vartype recipients: ~api_management_client.models.RecipientsContractProperties + :vartype recipients: ~azure.mgmt.apimanagement.models.RecipientsContractProperties """ _validation = { @@ -12272,7 +12885,7 @@ def __init__( *, title: Optional[str] = None, description: Optional[str] = None, - recipients: Optional["RecipientsContractProperties"] = None, + recipients: Optional["_models.RecipientsContractProperties"] = None, **kwargs ): """ @@ -12281,7 +12894,7 @@ def __init__( :keyword description: Description of the Notification. :paramtype description: str :keyword recipients: Recipient Parameter values. - :paramtype recipients: ~api_management_client.models.RecipientsContractProperties + :paramtype recipients: ~azure.mgmt.apimanagement.models.RecipientsContractProperties """ super(NotificationContract, self).__init__(**kwargs) self.title = title @@ -12328,7 +12941,7 @@ class OpenIdAuthenticationSettingsContract(msrest.serialization.Model): :vartype openid_provider_id: str :ivar bearer_token_sending_methods: How to send token to the server. :vartype bearer_token_sending_methods: list[str or - ~api_management_client.models.BearerTokenSendingMethods] + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethods] """ _attribute_map = { @@ -12340,7 +12953,7 @@ def __init__( self, *, openid_provider_id: Optional[str] = None, - bearer_token_sending_methods: Optional[List[Union[str, "BearerTokenSendingMethods"]]] = None, + bearer_token_sending_methods: Optional[List[Union[str, "_models.BearerTokenSendingMethods"]]] = None, **kwargs ): """ @@ -12348,7 +12961,7 @@ def __init__( :paramtype openid_provider_id: str :keyword bearer_token_sending_methods: How to send token to the server. :paramtype bearer_token_sending_methods: list[str or - ~api_management_client.models.BearerTokenSendingMethods] + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethods] """ super(OpenIdAuthenticationSettingsContract, self).__init__(**kwargs) self.openid_provider_id = openid_provider_id @@ -12359,7 +12972,7 @@ class OpenIdConnectProviderCollection(msrest.serialization.Model): """Paged OpenIdProviders list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.OpenidConnectProviderContract] + :vartype value: list[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -12375,14 +12988,14 @@ class OpenIdConnectProviderCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["OpenidConnectProviderContract"]] = None, + value: Optional[List["_models.OpenidConnectProviderContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.OpenidConnectProviderContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -12530,7 +13143,7 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{operation}. :vartype name: str :ivar display: The object that describes the operation. - :vartype display: ~api_management_client.models.OperationDisplay + :vartype display: ~azure.mgmt.apimanagement.models.OperationDisplay :ivar origin: The operation origin. :vartype origin: str :ivar properties: The operation properties. @@ -12548,7 +13161,7 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, properties: Optional[Any] = None, **kwargs @@ -12557,7 +13170,7 @@ def __init__( :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that describes the operation. - :paramtype display: ~api_management_client.models.OperationDisplay + :paramtype display: ~azure.mgmt.apimanagement.models.OperationDisplay :keyword origin: The operation origin. :paramtype origin: str :keyword properties: The operation properties. @@ -12576,7 +13189,7 @@ class OperationCollection(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Page values. - :vartype value: list[~api_management_client.models.OperationContract] + :vartype value: list[~azure.mgmt.apimanagement.models.OperationContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -12624,13 +13237,13 @@ class OperationContract(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar template_parameters: Collection of URL template parameters. - :vartype template_parameters: list[~api_management_client.models.ParameterContract] + :vartype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :ivar description: Description of the operation. May include HTML formatting tags. :vartype description: str :ivar request: An entity containing request details. - :vartype request: ~api_management_client.models.RequestContract + :vartype request: ~azure.mgmt.apimanagement.models.RequestContract :ivar responses: Array of Operation responses. - :vartype responses: list[~api_management_client.models.ResponseContract] + :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :ivar policies: Operation Policies. :vartype policies: str :ivar display_name: Operation Name. @@ -12669,10 +13282,10 @@ class OperationContract(Resource): def __init__( self, *, - template_parameters: Optional[List["ParameterContract"]] = None, + template_parameters: Optional[List["_models.ParameterContract"]] = None, description: Optional[str] = None, - request: Optional["RequestContract"] = None, - responses: Optional[List["ResponseContract"]] = None, + request: Optional["_models.RequestContract"] = None, + responses: Optional[List["_models.ResponseContract"]] = None, policies: Optional[str] = None, display_name: Optional[str] = None, method: Optional[str] = None, @@ -12681,13 +13294,13 @@ def __init__( ): """ :keyword template_parameters: Collection of URL template parameters. - :paramtype template_parameters: list[~api_management_client.models.ParameterContract] + :paramtype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :keyword description: Description of the operation. May include HTML formatting tags. :paramtype description: str :keyword request: An entity containing request details. - :paramtype request: ~api_management_client.models.RequestContract + :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract :keyword responses: Array of Operation responses. - :paramtype responses: list[~api_management_client.models.ResponseContract] + :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :keyword policies: Operation Policies. :paramtype policies: str :keyword display_name: Operation Name. @@ -12714,13 +13327,13 @@ class OperationEntityBaseContract(msrest.serialization.Model): """API Operation Entity Base Contract details. :ivar template_parameters: Collection of URL template parameters. - :vartype template_parameters: list[~api_management_client.models.ParameterContract] + :vartype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :ivar description: Description of the operation. May include HTML formatting tags. :vartype description: str :ivar request: An entity containing request details. - :vartype request: ~api_management_client.models.RequestContract + :vartype request: ~azure.mgmt.apimanagement.models.RequestContract :ivar responses: Array of Operation responses. - :vartype responses: list[~api_management_client.models.ResponseContract] + :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :ivar policies: Operation Policies. :vartype policies: str """ @@ -12740,22 +13353,22 @@ class OperationEntityBaseContract(msrest.serialization.Model): def __init__( self, *, - template_parameters: Optional[List["ParameterContract"]] = None, + template_parameters: Optional[List["_models.ParameterContract"]] = None, description: Optional[str] = None, - request: Optional["RequestContract"] = None, - responses: Optional[List["ResponseContract"]] = None, + request: Optional["_models.RequestContract"] = None, + responses: Optional[List["_models.ResponseContract"]] = None, policies: Optional[str] = None, **kwargs ): """ :keyword template_parameters: Collection of URL template parameters. - :paramtype template_parameters: list[~api_management_client.models.ParameterContract] + :paramtype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :keyword description: Description of the operation. May include HTML formatting tags. :paramtype description: str :keyword request: An entity containing request details. - :paramtype request: ~api_management_client.models.RequestContract + :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract :keyword responses: Array of Operation responses. - :paramtype responses: list[~api_management_client.models.ResponseContract] + :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :keyword policies: Operation Policies. :paramtype policies: str """ @@ -12773,13 +13386,13 @@ class OperationContractProperties(OperationEntityBaseContract): All required parameters must be populated in order to send to Azure. :ivar template_parameters: Collection of URL template parameters. - :vartype template_parameters: list[~api_management_client.models.ParameterContract] + :vartype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :ivar description: Description of the operation. May include HTML formatting tags. :vartype description: str :ivar request: An entity containing request details. - :vartype request: ~api_management_client.models.RequestContract + :vartype request: ~azure.mgmt.apimanagement.models.RequestContract :ivar responses: Array of Operation responses. - :vartype responses: list[~api_management_client.models.ResponseContract] + :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :ivar policies: Operation Policies. :vartype policies: str :ivar display_name: Required. Operation Name. @@ -12816,22 +13429,22 @@ def __init__( display_name: str, method: str, url_template: str, - template_parameters: Optional[List["ParameterContract"]] = None, + template_parameters: Optional[List["_models.ParameterContract"]] = None, description: Optional[str] = None, - request: Optional["RequestContract"] = None, - responses: Optional[List["ResponseContract"]] = None, + request: Optional["_models.RequestContract"] = None, + responses: Optional[List["_models.ResponseContract"]] = None, policies: Optional[str] = None, **kwargs ): """ :keyword template_parameters: Collection of URL template parameters. - :paramtype template_parameters: list[~api_management_client.models.ParameterContract] + :paramtype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :keyword description: Description of the operation. May include HTML formatting tags. :paramtype description: str :keyword request: An entity containing request details. - :paramtype request: ~api_management_client.models.RequestContract + :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract :keyword responses: Array of Operation responses. - :paramtype responses: list[~api_management_client.models.ResponseContract] + :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :keyword policies: Operation Policies. :paramtype policies: str :keyword display_name: Required. Operation Name. @@ -12899,7 +13512,7 @@ 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. :ivar value: List of operations supported by the resource provider. - :vartype value: list[~api_management_client.models.Operation] + :vartype value: list[~azure.mgmt.apimanagement.models.Operation] :ivar next_link: URL to get the next set of operation list results if there are any. :vartype next_link: str """ @@ -12912,13 +13525,13 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: List of operations supported by the resource provider. - :paramtype value: list[~api_management_client.models.Operation] + :paramtype value: list[~azure.mgmt.apimanagement.models.Operation] :keyword next_link: URL to get the next set of operation list results if there are any. :paramtype next_link: str """ @@ -12942,9 +13555,9 @@ class OperationResultContract(Resource): :vartype type: str :ivar id_properties_id: Operation result identifier. :vartype id_properties_id: str - :ivar status: Status of an async operation. Possible values include: "Started", "InProgress", + :ivar status: Status of an async operation. Known values are: "Started", "InProgress", "Succeeded", "Failed". - :vartype status: str or ~api_management_client.models.AsyncOperationStatus + :vartype status: str or ~azure.mgmt.apimanagement.models.AsyncOperationStatus :ivar started: Start time of an async operation. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. :vartype started: ~datetime.datetime @@ -12954,11 +13567,11 @@ class OperationResultContract(Resource): :ivar result_info: Optional result info. :vartype result_info: str :ivar error: Error Body Contract. - :vartype error: ~api_management_client.models.ErrorResponseBody + :vartype error: ~azure.mgmt.apimanagement.models.ErrorResponseBody :ivar action_log: This property if only provided as part of the TenantConfiguration_Validate operation. It contains the log the entities which will be updated/created/deleted as part of the TenantConfiguration_Deploy operation. - :vartype action_log: list[~api_management_client.models.OperationResultLogItemContract] + :vartype action_log: list[~azure.mgmt.apimanagement.models.OperationResultLogItemContract] """ _validation = { @@ -12985,19 +13598,19 @@ def __init__( self, *, id_properties_id: Optional[str] = None, - status: Optional[Union[str, "AsyncOperationStatus"]] = None, + status: Optional[Union[str, "_models.AsyncOperationStatus"]] = None, started: Optional[datetime.datetime] = None, updated: Optional[datetime.datetime] = None, result_info: Optional[str] = None, - error: Optional["ErrorResponseBody"] = None, + error: Optional["_models.ErrorResponseBody"] = None, **kwargs ): """ :keyword id_properties_id: Operation result identifier. :paramtype id_properties_id: str - :keyword status: Status of an async operation. Possible values include: "Started", - "InProgress", "Succeeded", "Failed". - :paramtype status: str or ~api_management_client.models.AsyncOperationStatus + :keyword status: Status of an async operation. Known values are: "Started", "InProgress", + "Succeeded", "Failed". + :paramtype status: str or ~azure.mgmt.apimanagement.models.AsyncOperationStatus :keyword started: Start time of an async operation. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. :paramtype started: ~datetime.datetime @@ -13007,7 +13620,7 @@ def __init__( :keyword result_info: Optional result info. :paramtype result_info: str :keyword error: Error Body Contract. - :paramtype error: ~api_management_client.models.ErrorResponseBody + :paramtype error: ~azure.mgmt.apimanagement.models.ErrorResponseBody """ super(OperationResultContract, self).__init__(**kwargs) self.id_properties_id = id_properties_id @@ -13129,13 +13742,13 @@ class OperationUpdateContract(msrest.serialization.Model): """API Operation Update Contract details. :ivar template_parameters: Collection of URL template parameters. - :vartype template_parameters: list[~api_management_client.models.ParameterContract] + :vartype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :ivar description: Description of the operation. May include HTML formatting tags. :vartype description: str :ivar request: An entity containing request details. - :vartype request: ~api_management_client.models.RequestContract + :vartype request: ~azure.mgmt.apimanagement.models.RequestContract :ivar responses: Array of Operation responses. - :vartype responses: list[~api_management_client.models.ResponseContract] + :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :ivar policies: Operation Policies. :vartype policies: str :ivar display_name: Operation Name. @@ -13168,10 +13781,10 @@ class OperationUpdateContract(msrest.serialization.Model): def __init__( self, *, - template_parameters: Optional[List["ParameterContract"]] = None, + template_parameters: Optional[List["_models.ParameterContract"]] = None, description: Optional[str] = None, - request: Optional["RequestContract"] = None, - responses: Optional[List["ResponseContract"]] = None, + request: Optional["_models.RequestContract"] = None, + responses: Optional[List["_models.ResponseContract"]] = None, policies: Optional[str] = None, display_name: Optional[str] = None, method: Optional[str] = None, @@ -13180,13 +13793,13 @@ def __init__( ): """ :keyword template_parameters: Collection of URL template parameters. - :paramtype template_parameters: list[~api_management_client.models.ParameterContract] + :paramtype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :keyword description: Description of the operation. May include HTML formatting tags. :paramtype description: str :keyword request: An entity containing request details. - :paramtype request: ~api_management_client.models.RequestContract + :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract :keyword responses: Array of Operation responses. - :paramtype responses: list[~api_management_client.models.ResponseContract] + :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :keyword policies: Operation Policies. :paramtype policies: str :keyword display_name: Operation Name. @@ -13213,13 +13826,13 @@ class OperationUpdateContractProperties(OperationEntityBaseContract): """Operation Update Contract Properties. :ivar template_parameters: Collection of URL template parameters. - :vartype template_parameters: list[~api_management_client.models.ParameterContract] + :vartype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :ivar description: Description of the operation. May include HTML formatting tags. :vartype description: str :ivar request: An entity containing request details. - :vartype request: ~api_management_client.models.RequestContract + :vartype request: ~azure.mgmt.apimanagement.models.RequestContract :ivar responses: Array of Operation responses. - :vartype responses: list[~api_management_client.models.ResponseContract] + :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :ivar policies: Operation Policies. :vartype policies: str :ivar display_name: Operation Name. @@ -13252,10 +13865,10 @@ class OperationUpdateContractProperties(OperationEntityBaseContract): def __init__( self, *, - template_parameters: Optional[List["ParameterContract"]] = None, + template_parameters: Optional[List["_models.ParameterContract"]] = None, description: Optional[str] = None, - request: Optional["RequestContract"] = None, - responses: Optional[List["ResponseContract"]] = None, + request: Optional["_models.RequestContract"] = None, + responses: Optional[List["_models.ResponseContract"]] = None, policies: Optional[str] = None, display_name: Optional[str] = None, method: Optional[str] = None, @@ -13264,13 +13877,13 @@ def __init__( ): """ :keyword template_parameters: Collection of URL template parameters. - :paramtype template_parameters: list[~api_management_client.models.ParameterContract] + :paramtype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :keyword description: Description of the operation. May include HTML formatting tags. :paramtype description: str :keyword request: An entity containing request details. - :paramtype request: ~api_management_client.models.RequestContract + :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract :keyword responses: Array of Operation responses. - :paramtype responses: list[~api_management_client.models.ResponseContract] + :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] :keyword policies: Operation Policies. :paramtype policies: str :keyword display_name: Operation Name. @@ -13295,7 +13908,7 @@ class OutboundEnvironmentEndpoint(msrest.serialization.Model): Storage, Azure SQL Database, and Azure Active Directory. :vartype category: str :ivar endpoints: The endpoints that the Api Management Service reaches the service at. - :vartype endpoints: list[~api_management_client.models.EndpointDependency] + :vartype endpoints: list[~azure.mgmt.apimanagement.models.EndpointDependency] """ _attribute_map = { @@ -13307,7 +13920,7 @@ def __init__( self, *, category: Optional[str] = None, - endpoints: Optional[List["EndpointDependency"]] = None, + endpoints: Optional[List["_models.EndpointDependency"]] = None, **kwargs ): """ @@ -13315,7 +13928,7 @@ def __init__( Storage, Azure SQL Database, and Azure Active Directory. :paramtype category: str :keyword endpoints: The endpoints that the Api Management Service reaches the service at. - :paramtype endpoints: list[~api_management_client.models.EndpointDependency] + :paramtype endpoints: list[~azure.mgmt.apimanagement.models.EndpointDependency] """ super(OutboundEnvironmentEndpoint, self).__init__(**kwargs) self.category = category @@ -13330,7 +13943,7 @@ class OutboundEnvironmentEndpointList(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar value: Required. Collection of resources. - :vartype value: list[~api_management_client.models.OutboundEnvironmentEndpoint] + :vartype value: list[~azure.mgmt.apimanagement.models.OutboundEnvironmentEndpoint] :ivar next_link: Link to next page of resources. :vartype next_link: str """ @@ -13348,12 +13961,12 @@ class OutboundEnvironmentEndpointList(msrest.serialization.Model): def __init__( self, *, - value: List["OutboundEnvironmentEndpoint"], + value: List["_models.OutboundEnvironmentEndpoint"], **kwargs ): """ :keyword value: Required. Collection of resources. - :paramtype value: list[~api_management_client.models.OutboundEnvironmentEndpoint] + :paramtype value: list[~azure.mgmt.apimanagement.models.OutboundEnvironmentEndpoint] """ super(OutboundEnvironmentEndpointList, self).__init__(**kwargs) self.value = value @@ -13382,7 +13995,7 @@ class ParameterContract(msrest.serialization.Model): :ivar type_name: Type name defined by the schema. :vartype type_name: str :ivar examples: Exampled defined for the parameter. - :vartype examples: dict[str, ~api_management_client.models.ParameterExampleContract] + :vartype examples: dict[str, ~azure.mgmt.apimanagement.models.ParameterExampleContract] """ _validation = { @@ -13413,7 +14026,7 @@ def __init__( values: Optional[List[str]] = None, schema_id: Optional[str] = None, type_name: Optional[str] = None, - examples: Optional[Dict[str, "ParameterExampleContract"]] = None, + examples: Optional[Dict[str, "_models.ParameterExampleContract"]] = None, **kwargs ): """ @@ -13434,7 +14047,7 @@ def __init__( :keyword type_name: Type name defined by the schema. :paramtype type_name: str :keyword examples: Exampled defined for the parameter. - :paramtype examples: dict[str, ~api_management_client.models.ParameterExampleContract] + :paramtype examples: dict[str, ~azure.mgmt.apimanagement.models.ParameterExampleContract] """ super(ParameterContract, self).__init__(**kwargs) self.name = name @@ -13498,39 +14111,209 @@ class PipelineDiagnosticSettings(msrest.serialization.Model): """Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. :ivar request: Diagnostic settings for request. - :vartype request: ~api_management_client.models.HttpMessageDiagnostic + :vartype request: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic :ivar response: Diagnostic settings for response. - :vartype response: ~api_management_client.models.HttpMessageDiagnostic + :vartype response: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic + """ + + _attribute_map = { + 'request': {'key': 'request', 'type': 'HttpMessageDiagnostic'}, + 'response': {'key': 'response', 'type': 'HttpMessageDiagnostic'}, + } + + def __init__( + self, + *, + request: Optional["_models.HttpMessageDiagnostic"] = None, + response: Optional["_models.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 + + +class PolicyCollection(msrest.serialization.Model): + """The response of the list policy operation. + + :ivar value: Policy Contract value. + :vartype value: list[~azure.mgmt.apimanagement.models.PolicyContract] + :ivar count: Total record count number. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyContract]'}, + 'count': {'key': 'count', 'type': 'long'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.PolicyContract"]] = None, + count: Optional[int] = None, + 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 + self.next_link = next_link + + +class PolicyContract(Resource): + """Policy Contract details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar value: Contents of the Policy as defined by the format. + :vartype value: str + :ivar format: Format of the policyContent. Known values are: "xml", "xml-link", "rawxml", + "rawxml-link". Default value: "xml". + :vartype format: str or ~azure.mgmt.apimanagement.models.PolicyContentFormat + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'value': {'key': 'properties.value', 'type': 'str'}, + 'format': {'key': 'properties.format', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[str] = None, + format: Optional[Union[str, "_models.PolicyContentFormat"]] = "xml", + **kwargs + ): + """ + :keyword value: Contents of the Policy as defined by the format. + :paramtype value: str + :keyword format: Format of the policyContent. Known values are: "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 + + +class PolicyDescriptionCollection(msrest.serialization.Model): + """Descriptions of APIM policies. + + :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 = { + 'value': {'key': 'value', 'type': '[PolicyDescriptionContract]'}, + 'count': {'key': 'count', 'type': 'long'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.PolicyDescriptionContract"]] = None, + 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 + + +class PolicyDescriptionContract(Resource): + """Policy description details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar description: Policy description. + :vartype description: str + :ivar scope: Binary OR value of the Snippet scope. + :vartype scope: long """ + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'description': {'readonly': True}, + 'scope': {'readonly': True}, + } + _attribute_map = { - 'request': {'key': 'request', 'type': 'HttpMessageDiagnostic'}, - 'response': {'key': 'response', 'type': 'HttpMessageDiagnostic'}, + '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, - *, - request: Optional["HttpMessageDiagnostic"] = None, - response: Optional["HttpMessageDiagnostic"] = None, **kwargs ): """ - :keyword request: Diagnostic settings for request. - :paramtype request: ~api_management_client.models.HttpMessageDiagnostic - :keyword response: Diagnostic settings for response. - :paramtype response: ~api_management_client.models.HttpMessageDiagnostic """ - super(PipelineDiagnosticSettings, self).__init__(**kwargs) - self.request = request - self.response = response + super(PolicyDescriptionContract, self).__init__(**kwargs) + self.description = None + self.scope = None -class PolicyCollection(msrest.serialization.Model): - """The response of the list policy operation. +class PolicyFragmentCollection(msrest.serialization.Model): + """The response of the get policy fragments operation. - :ivar value: Policy Contract value. - :vartype value: list[~api_management_client.models.PolicyContract] + :ivar value: Policy fragment contract value. + :vartype value: list[~azure.mgmt.apimanagement.models.PolicyFragmentContract] :ivar count: Total record count number. :vartype count: long :ivar next_link: Next page link if any. @@ -13538,7 +14321,7 @@ class PolicyCollection(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyContract]'}, + 'value': {'key': 'value', 'type': '[PolicyFragmentContract]'}, 'count': {'key': 'count', 'type': 'long'}, 'next_link': {'key': 'nextLink', 'type': 'str'}, } @@ -13546,27 +14329,27 @@ class PolicyCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PolicyContract"]] = None, + value: Optional[List["_models.PolicyFragmentContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ - :keyword value: Policy Contract value. - :paramtype value: list[~api_management_client.models.PolicyContract] + :keyword value: Policy fragment contract value. + :paramtype value: list[~azure.mgmt.apimanagement.models.PolicyFragmentContract] :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) + super(PolicyFragmentCollection, self).__init__(**kwargs) self.value = value self.count = count self.next_link = next_link -class PolicyContract(Resource): - """Policy Contract details. +class PolicyFragmentContract(Resource): + """Policy fragment contract details. Variables are only populated by the server, and will be ignored when sending a request. @@ -13578,17 +14361,19 @@ class PolicyContract(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar value: Contents of the Policy as defined by the format. + :ivar value: Contents of the policy fragment. :vartype value: str - :ivar format: Format of the policyContent. Possible values include: "xml", "xml-link", - "rawxml", "rawxml-link". Default value: "xml". - :vartype format: str or ~api_management_client.models.PolicyContentFormat + :ivar description: Policy fragment description. + :vartype description: str + :ivar format: Format of the policy fragment content. Known values are: "xml", "rawxml". + :vartype format: str or ~azure.mgmt.apimanagement.models.PolicyFragmentContentFormat """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'description': {'max_length': 1000, 'min_length': 0}, } _attribute_map = { @@ -13596,6 +14381,7 @@ class PolicyContract(Resource): 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'value': {'key': 'properties.value', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, 'format': {'key': 'properties.format', 'type': 'str'}, } @@ -13603,55 +14389,61 @@ def __init__( self, *, value: Optional[str] = None, - format: Optional[Union[str, "PolicyContentFormat"]] = "xml", + description: Optional[str] = None, + format: Optional[Union[str, "_models.PolicyFragmentContentFormat"]] = None, **kwargs ): """ - :keyword value: Contents of the Policy as defined by the format. + :keyword value: Contents of the policy fragment. :paramtype value: str - :keyword format: Format of the policyContent. Possible values include: "xml", "xml-link", - "rawxml", "rawxml-link". Default value: "xml". - :paramtype format: str or ~api_management_client.models.PolicyContentFormat + :keyword description: Policy fragment description. + :paramtype description: str + :keyword format: Format of the policy fragment content. Known values are: "xml", "rawxml". + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyFragmentContentFormat """ - super(PolicyContract, self).__init__(**kwargs) + super(PolicyFragmentContract, self).__init__(**kwargs) self.value = value + self.description = description self.format = format -class PolicyDescriptionCollection(msrest.serialization.Model): - """Descriptions of APIM policies. +class PortalConfigCollection(msrest.serialization.Model): + """The collection of the developer portal configurations. - :ivar value: Descriptions of APIM policies. - :vartype value: list[~api_management_client.models.PolicyDescriptionContract] - :ivar count: Total record count number. - :vartype count: long + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The developer portal configurations. + :vartype value: list[~azure.mgmt.apimanagement.models.PortalConfigContract] + :ivar next_link: Next page link if any. + :vartype next_link: str """ + _validation = { + 'next_link': {'readonly': True}, + } + _attribute_map = { - 'value': {'key': 'value', 'type': '[PolicyDescriptionContract]'}, - 'count': {'key': 'count', 'type': 'long'}, + 'value': {'key': 'value', 'type': '[PortalConfigContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } def __init__( self, *, - value: Optional[List["PolicyDescriptionContract"]] = None, - count: Optional[int] = None, + value: Optional[List["_models.PortalConfigContract"]] = None, **kwargs ): """ - :keyword value: Descriptions of APIM policies. - :paramtype value: list[~api_management_client.models.PolicyDescriptionContract] - :keyword count: Total record count number. - :paramtype count: long + :keyword value: The developer portal configurations. + :paramtype value: list[~azure.mgmt.apimanagement.models.PortalConfigContract] """ - super(PolicyDescriptionCollection, self).__init__(**kwargs) + super(PortalConfigCollection, self).__init__(**kwargs) self.value = value - self.count = count + self.next_link = None -class PolicyDescriptionContract(Resource): - """Policy description details. +class PortalConfigContract(Resource): + """The developer portal configuration contract. Variables are only populated by the server, and will be ignored when sending a request. @@ -13663,37 +14455,270 @@ class PolicyDescriptionContract(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 - :ivar scope: Binary OR value of the Snippet scope. - :vartype scope: long + :ivar enable_basic_auth: Enable or disable Basic authentication method. + :vartype enable_basic_auth: bool + :ivar signin: + :vartype signin: ~azure.mgmt.apimanagement.models.PortalConfigPropertiesSignin + :ivar signup: + :vartype signup: ~azure.mgmt.apimanagement.models.PortalConfigPropertiesSignup + :ivar delegation: The developer portal delegation settings. + :vartype delegation: ~azure.mgmt.apimanagement.models.PortalConfigDelegationProperties + :ivar cors: The developer portal Cross-Origin Resource Sharing (CORS) settings. + :vartype cors: ~azure.mgmt.apimanagement.models.PortalConfigCorsProperties + :ivar csp: The developer portal Content Security Policy (CSP) settings. + :vartype csp: ~azure.mgmt.apimanagement.models.PortalConfigCspProperties """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - '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'}, + 'enable_basic_auth': {'key': 'properties.enableBasicAuth', 'type': 'bool'}, + 'signin': {'key': 'properties.signin', 'type': 'PortalConfigPropertiesSignin'}, + 'signup': {'key': 'properties.signup', 'type': 'PortalConfigPropertiesSignup'}, + 'delegation': {'key': 'properties.delegation', 'type': 'PortalConfigDelegationProperties'}, + 'cors': {'key': 'properties.cors', 'type': 'PortalConfigCorsProperties'}, + 'csp': {'key': 'properties.csp', 'type': 'PortalConfigCspProperties'}, } def __init__( self, + *, + enable_basic_auth: Optional[bool] = True, + signin: Optional["_models.PortalConfigPropertiesSignin"] = None, + signup: Optional["_models.PortalConfigPropertiesSignup"] = None, + delegation: Optional["_models.PortalConfigDelegationProperties"] = None, + cors: Optional["_models.PortalConfigCorsProperties"] = None, + csp: Optional["_models.PortalConfigCspProperties"] = None, **kwargs ): """ + :keyword enable_basic_auth: Enable or disable Basic authentication method. + :paramtype enable_basic_auth: bool + :keyword signin: + :paramtype signin: ~azure.mgmt.apimanagement.models.PortalConfigPropertiesSignin + :keyword signup: + :paramtype signup: ~azure.mgmt.apimanagement.models.PortalConfigPropertiesSignup + :keyword delegation: The developer portal delegation settings. + :paramtype delegation: ~azure.mgmt.apimanagement.models.PortalConfigDelegationProperties + :keyword cors: The developer portal Cross-Origin Resource Sharing (CORS) settings. + :paramtype cors: ~azure.mgmt.apimanagement.models.PortalConfigCorsProperties + :keyword csp: The developer portal Content Security Policy (CSP) settings. + :paramtype csp: ~azure.mgmt.apimanagement.models.PortalConfigCspProperties """ - super(PolicyDescriptionContract, self).__init__(**kwargs) - self.description = None - self.scope = None + super(PortalConfigContract, self).__init__(**kwargs) + self.enable_basic_auth = enable_basic_auth + self.signin = signin + self.signup = signup + self.delegation = delegation + self.cors = cors + self.csp = csp + + +class PortalConfigCorsProperties(msrest.serialization.Model): + """The developer portal Cross-Origin Resource Sharing (CORS) settings. + + :ivar allowed_origins: Allowed origins, e.g. ``https://trusted.com``. + :vartype allowed_origins: list[str] + """ + + _attribute_map = { + 'allowed_origins': {'key': 'allowedOrigins', 'type': '[str]'}, + } + + def __init__( + self, + *, + allowed_origins: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword allowed_origins: Allowed origins, e.g. ``https://trusted.com``. + :paramtype allowed_origins: list[str] + """ + super(PortalConfigCorsProperties, self).__init__(**kwargs) + self.allowed_origins = allowed_origins + + +class PortalConfigCspProperties(msrest.serialization.Model): + """The developer portal Content Security Policy (CSP) settings. + + :ivar mode: The mode of the developer portal Content Security Policy (CSP). Known values are: + "enabled", "disabled", "reportOnly". Default value: "disabled". + :vartype mode: str or ~azure.mgmt.apimanagement.models.PortalSettingsCspMode + :ivar report_uri: The URLs used by the browser to report CSP violations. + :vartype report_uri: list[str] + :ivar allowed_sources: Allowed sources, e.g. ``*.trusted.com``\ , ``trusted.com``\ , + ``https://``. + :vartype allowed_sources: list[str] + """ + + _attribute_map = { + 'mode': {'key': 'mode', 'type': 'str'}, + 'report_uri': {'key': 'reportUri', 'type': '[str]'}, + 'allowed_sources': {'key': 'allowedSources', 'type': '[str]'}, + } + + def __init__( + self, + *, + mode: Optional[Union[str, "_models.PortalSettingsCspMode"]] = "disabled", + report_uri: Optional[List[str]] = None, + allowed_sources: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword mode: The mode of the developer portal Content Security Policy (CSP). Known values + are: "enabled", "disabled", "reportOnly". Default value: "disabled". + :paramtype mode: str or ~azure.mgmt.apimanagement.models.PortalSettingsCspMode + :keyword report_uri: The URLs used by the browser to report CSP violations. + :paramtype report_uri: list[str] + :keyword allowed_sources: Allowed sources, e.g. ``*.trusted.com``\ , ``trusted.com``\ , + ``https://``. + :paramtype allowed_sources: list[str] + """ + super(PortalConfigCspProperties, self).__init__(**kwargs) + self.mode = mode + self.report_uri = report_uri + self.allowed_sources = allowed_sources + + +class PortalConfigDelegationProperties(msrest.serialization.Model): + """PortalConfigDelegationProperties. + + :ivar delegate_registration: Enable or disable delegation for user registration. + :vartype delegate_registration: bool + :ivar delegate_subscription: Enable or disable delegation for product subscriptions. + :vartype delegate_subscription: bool + :ivar delegation_url: A delegation endpoint URL. + :vartype delegation_url: str + :ivar validation_key: A base64-encoded validation key to ensure requests originate from Azure + API Management service. + :vartype validation_key: str + """ + + _attribute_map = { + 'delegate_registration': {'key': 'delegateRegistration', 'type': 'bool'}, + 'delegate_subscription': {'key': 'delegateSubscription', 'type': 'bool'}, + 'delegation_url': {'key': 'delegationUrl', 'type': 'str'}, + 'validation_key': {'key': 'validationKey', 'type': 'str'}, + } + + def __init__( + self, + *, + delegate_registration: Optional[bool] = False, + delegate_subscription: Optional[bool] = False, + delegation_url: Optional[str] = None, + validation_key: Optional[str] = None, + **kwargs + ): + """ + :keyword delegate_registration: Enable or disable delegation for user registration. + :paramtype delegate_registration: bool + :keyword delegate_subscription: Enable or disable delegation for product subscriptions. + :paramtype delegate_subscription: bool + :keyword delegation_url: A delegation endpoint URL. + :paramtype delegation_url: str + :keyword validation_key: A base64-encoded validation key to ensure requests originate from + Azure API Management service. + :paramtype validation_key: str + """ + super(PortalConfigDelegationProperties, self).__init__(**kwargs) + self.delegate_registration = delegate_registration + self.delegate_subscription = delegate_subscription + self.delegation_url = delegation_url + self.validation_key = validation_key + + +class PortalConfigPropertiesSignin(msrest.serialization.Model): + """PortalConfigPropertiesSignin. + + :ivar require: Redirect anonymous users to the sign-in page. + :vartype require: bool + """ + + _attribute_map = { + 'require': {'key': 'require', 'type': 'bool'}, + } + + def __init__( + self, + *, + require: Optional[bool] = False, + **kwargs + ): + """ + :keyword require: Redirect anonymous users to the sign-in page. + :paramtype require: bool + """ + super(PortalConfigPropertiesSignin, self).__init__(**kwargs) + self.require = require + + +class PortalConfigPropertiesSignup(msrest.serialization.Model): + """PortalConfigPropertiesSignup. + + :ivar terms_of_service: Terms of service settings. + :vartype terms_of_service: + ~azure.mgmt.apimanagement.models.PortalConfigTermsOfServiceProperties + """ + + _attribute_map = { + 'terms_of_service': {'key': 'termsOfService', 'type': 'PortalConfigTermsOfServiceProperties'}, + } + + def __init__( + self, + *, + terms_of_service: Optional["_models.PortalConfigTermsOfServiceProperties"] = None, + **kwargs + ): + """ + :keyword terms_of_service: Terms of service settings. + :paramtype terms_of_service: + ~azure.mgmt.apimanagement.models.PortalConfigTermsOfServiceProperties + """ + super(PortalConfigPropertiesSignup, self).__init__(**kwargs) + self.terms_of_service = terms_of_service + + +class PortalConfigTermsOfServiceProperties(msrest.serialization.Model): + """Terms of service contract properties. + + :ivar text: A terms of service text. + :vartype text: str + :ivar require_consent: Ask user for consent to the terms of service. + :vartype require_consent: bool + """ + + _attribute_map = { + 'text': {'key': 'text', 'type': 'str'}, + 'require_consent': {'key': 'requireConsent', 'type': 'bool'}, + } + + def __init__( + self, + *, + text: Optional[str] = None, + require_consent: Optional[bool] = False, + **kwargs + ): + """ + :keyword text: A terms of service text. + :paramtype text: str + :keyword require_consent: Ask user for consent to the terms of service. + :paramtype require_consent: bool + """ + super(PortalConfigTermsOfServiceProperties, self).__init__(**kwargs) + self.text = text + self.require_consent = require_consent class PortalDelegationSettings(Resource): @@ -13715,10 +14740,11 @@ class PortalDelegationSettings(Resource): from Azure API Management. :vartype validation_key: str :ivar subscriptions: Subscriptions delegation settings. - :vartype subscriptions: ~api_management_client.models.SubscriptionsDelegationSettingsProperties + :vartype subscriptions: + ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties :ivar user_registration: User registration delegation settings. :vartype user_registration: - ~api_management_client.models.RegistrationDelegationSettingsProperties + ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties """ _validation = { @@ -13742,8 +14768,8 @@ def __init__( *, url: Optional[str] = None, validation_key: Optional[str] = None, - subscriptions: Optional["SubscriptionsDelegationSettingsProperties"] = None, - user_registration: Optional["RegistrationDelegationSettingsProperties"] = None, + subscriptions: Optional["_models.SubscriptionsDelegationSettingsProperties"] = None, + user_registration: Optional["_models.RegistrationDelegationSettingsProperties"] = None, **kwargs ): """ @@ -13754,10 +14780,10 @@ def __init__( :paramtype validation_key: str :keyword subscriptions: Subscriptions delegation settings. :paramtype subscriptions: - ~api_management_client.models.SubscriptionsDelegationSettingsProperties + ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties :keyword user_registration: User registration delegation settings. :paramtype user_registration: - ~api_management_client.models.RegistrationDelegationSettingsProperties + ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties """ super(PortalDelegationSettings, self).__init__(**kwargs) self.url = url @@ -13772,7 +14798,7 @@ class PortalRevisionCollection(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Collection of portal revisions. - :vartype value: list[~api_management_client.models.PortalRevisionContract] + :vartype value: list[~azure.mgmt.apimanagement.models.PortalRevisionContract] :ivar next_link: Next page link, if any. :vartype next_link: str """ @@ -13815,9 +14841,9 @@ class PortalRevisionContract(Resource): :vartype description: str :ivar status_details: Portal revision publishing status details. :vartype status_details: str - :ivar status: Status of the portal's revision. Possible values include: "pending", - "publishing", "completed", "failed". - :vartype status: str or ~api_management_client.models.PortalRevisionStatus + :ivar status: Status of the portal's revision. Known values are: "pending", "publishing", + "completed", "failed". + :vartype status: str or ~azure.mgmt.apimanagement.models.PortalRevisionStatus :ivar is_current: Indicates if the portal's revision is public. :vartype is_current: bool :ivar created_date_time: Portal's revision creation date and time. @@ -13875,7 +14901,7 @@ class PortalSettingsCollection(msrest.serialization.Model): """Descriptions of APIM policies. :ivar value: Descriptions of APIM policies. - :vartype value: list[~api_management_client.models.PortalSettingsContract] + :vartype value: list[~azure.mgmt.apimanagement.models.PortalSettingsContract] :ivar count: Total record count number. :vartype count: long """ @@ -13888,13 +14914,13 @@ class PortalSettingsCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PortalSettingsContract"]] = None, + value: Optional[List["_models.PortalSettingsContract"]] = None, count: Optional[int] = None, **kwargs ): """ :keyword value: Descriptions of APIM policies. - :paramtype value: list[~api_management_client.models.PortalSettingsContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.PortalSettingsContract] :keyword count: Total record count number. :paramtype count: long """ @@ -13922,14 +14948,15 @@ class PortalSettingsContract(Resource): from Azure API Management. :vartype validation_key: str :ivar subscriptions: Subscriptions delegation settings. - :vartype subscriptions: ~api_management_client.models.SubscriptionsDelegationSettingsProperties + :vartype subscriptions: + ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties :ivar user_registration: User registration delegation settings. :vartype user_registration: - ~api_management_client.models.RegistrationDelegationSettingsProperties + ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties :ivar enabled: Redirect Anonymous users to the Sign-In page. :vartype enabled: bool :ivar terms_of_service: Terms of service contract properties. - :vartype terms_of_service: ~api_management_client.models.TermsOfServiceProperties + :vartype terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties """ _validation = { @@ -13955,10 +14982,10 @@ def __init__( *, url: Optional[str] = None, validation_key: Optional[str] = None, - subscriptions: Optional["SubscriptionsDelegationSettingsProperties"] = None, - user_registration: Optional["RegistrationDelegationSettingsProperties"] = None, + subscriptions: Optional["_models.SubscriptionsDelegationSettingsProperties"] = None, + user_registration: Optional["_models.RegistrationDelegationSettingsProperties"] = None, enabled: Optional[bool] = None, - terms_of_service: Optional["TermsOfServiceProperties"] = None, + terms_of_service: Optional["_models.TermsOfServiceProperties"] = None, **kwargs ): """ @@ -13969,14 +14996,14 @@ def __init__( :paramtype validation_key: str :keyword subscriptions: Subscriptions delegation settings. :paramtype subscriptions: - ~api_management_client.models.SubscriptionsDelegationSettingsProperties + ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties :keyword user_registration: User registration delegation settings. :paramtype user_registration: - ~api_management_client.models.RegistrationDelegationSettingsProperties + ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties :keyword enabled: Redirect Anonymous users to the Sign-In page. :paramtype enabled: bool :keyword terms_of_service: Terms of service contract properties. - :paramtype terms_of_service: ~api_management_client.models.TermsOfServiceProperties + :paramtype terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties """ super(PortalSettingsContract, self).__init__(**kwargs) self.url = url @@ -14072,7 +15099,7 @@ class PortalSignupSettings(Resource): :ivar enabled: Allow users to sign up on a developer portal. :vartype enabled: bool :ivar terms_of_service: Terms of service contract properties. - :vartype terms_of_service: ~api_management_client.models.TermsOfServiceProperties + :vartype terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties """ _validation = { @@ -14093,14 +15120,14 @@ def __init__( self, *, enabled: Optional[bool] = None, - terms_of_service: Optional["TermsOfServiceProperties"] = None, + terms_of_service: Optional["_models.TermsOfServiceProperties"] = None, **kwargs ): """ :keyword enabled: Allow users to sign up on a developer portal. :paramtype enabled: bool :keyword terms_of_service: Terms of service contract properties. - :paramtype terms_of_service: ~api_management_client.models.TermsOfServiceProperties + :paramtype terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties """ super(PortalSignupSettings, self).__init__(**kwargs) self.enabled = enabled @@ -14148,15 +15175,15 @@ class PrivateEndpointConnection(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar private_endpoint: The resource of private end point. - :vartype private_endpoint: ~api_management_client.models.PrivateEndpoint + :vartype private_endpoint: ~azure.mgmt.apimanagement.models.PrivateEndpoint :ivar private_link_service_connection_state: A collection of information about the state of the connection between service consumer and provider. :vartype private_link_service_connection_state: - ~api_management_client.models.PrivateLinkServiceConnectionState + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Possible values include: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", "Failed". :vartype provisioning_state: str or - ~api_management_client.models.PrivateEndpointConnectionProvisioningState + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionProvisioningState """ _validation = { @@ -14178,17 +15205,17 @@ class PrivateEndpointConnection(Resource): def __init__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ :keyword private_endpoint: The resource of private end point. - :paramtype private_endpoint: ~api_management_client.models.PrivateEndpoint + :paramtype private_endpoint: ~azure.mgmt.apimanagement.models.PrivateEndpoint :keyword private_link_service_connection_state: A collection of information about the state of the connection between service consumer and provider. :paramtype private_link_service_connection_state: - ~api_management_client.models.PrivateLinkServiceConnectionState + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState """ super(PrivateEndpointConnection, self).__init__(**kwargs) self.private_endpoint = private_endpoint @@ -14200,7 +15227,7 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """List of private endpoint connection associated with the specified storage account. :ivar value: Array of private endpoint connections. - :vartype value: list[~api_management_client.models.PrivateEndpointConnection] + :vartype value: list[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] """ _attribute_map = { @@ -14210,12 +15237,12 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs ): """ :keyword value: Array of private endpoint connections. - :paramtype value: list[~api_management_client.models.PrivateEndpointConnection] + :paramtype value: list[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] """ super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) self.value = value @@ -14227,7 +15254,8 @@ class PrivateEndpointConnectionRequest(msrest.serialization.Model): :ivar id: Private Endpoint Connection Resource Id. :vartype id: str :ivar properties: The connection state of the private endpoint connection. - :vartype properties: ~api_management_client.models.PrivateEndpointConnectionRequestProperties + :vartype properties: + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequestProperties """ _attribute_map = { @@ -14239,14 +15267,15 @@ def __init__( self, *, id: Optional[str] = None, - properties: Optional["PrivateEndpointConnectionRequestProperties"] = None, + properties: Optional["_models.PrivateEndpointConnectionRequestProperties"] = None, **kwargs ): """ :keyword id: Private Endpoint Connection Resource Id. :paramtype id: str :keyword properties: The connection state of the private endpoint connection. - :paramtype properties: ~api_management_client.models.PrivateEndpointConnectionRequestProperties + :paramtype properties: + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequestProperties """ super(PrivateEndpointConnectionRequest, self).__init__(**kwargs) self.id = id @@ -14259,7 +15288,7 @@ class PrivateEndpointConnectionRequestProperties(msrest.serialization.Model): :ivar private_link_service_connection_state: A collection of information about the state of the connection between service consumer and provider. :vartype private_link_service_connection_state: - ~api_management_client.models.PrivateLinkServiceConnectionState + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState """ _attribute_map = { @@ -14269,14 +15298,14 @@ class PrivateEndpointConnectionRequestProperties(msrest.serialization.Model): def __init__( self, *, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ :keyword private_link_service_connection_state: A collection of information about the state of the connection between service consumer and provider. :paramtype private_link_service_connection_state: - ~api_management_client.models.PrivateLinkServiceConnectionState + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState """ super(PrivateEndpointConnectionRequestProperties, self).__init__(**kwargs) self.private_link_service_connection_state = private_link_service_connection_state @@ -14340,7 +15369,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """A list of private link resources. :ivar value: Array of private link resources. - :vartype value: list[~api_management_client.models.PrivateLinkResource] + :vartype value: list[~azure.mgmt.apimanagement.models.PrivateLinkResource] """ _attribute_map = { @@ -14350,12 +15379,12 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateLinkResource"]] = None, + value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs ): """ :keyword value: Array of private link resources. - :paramtype value: list[~api_management_client.models.PrivateLinkResource] + :paramtype value: list[~azure.mgmt.apimanagement.models.PrivateLinkResource] """ super(PrivateLinkResourceListResult, self).__init__(**kwargs) self.value = value @@ -14365,8 +15394,8 @@ 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 ~api_management_client.models.PrivateEndpointServiceConnectionStatus + of the service. Known values are: "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 @@ -14383,15 +15412,16 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): def __init__( self, *, - status: Optional[Union[str, "PrivateEndpointServiceConnectionStatus"]] = None, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, description: Optional[str] = None, actions_required: Optional[str] = None, **kwargs ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Possible values include: "Pending", "Approved", "Rejected". - :paramtype status: str or ~api_management_client.models.PrivateEndpointServiceConnectionStatus + owner of the service. Known values are: "Pending", "Approved", "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 @@ -14408,7 +15438,7 @@ class ProductCollection(msrest.serialization.Model): """Paged Products list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.ProductContract] + :vartype value: list[~azure.mgmt.apimanagement.models.ProductContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -14424,14 +15454,14 @@ class ProductCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ProductContract"]] = None, + value: Optional[List["_models.ProductContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.ProductContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.ProductContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -14480,8 +15510,8 @@ class ProductContract(Resource): :vartype subscriptions_limit: int :ivar state: whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible only to administrators. Default state - of Product is notPublished. Possible values include: "notPublished", "published". - :vartype state: str or ~api_management_client.models.ProductState + of Product is notPublished. Known values are: "notPublished", "published". + :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState :ivar display_name: Product name. :vartype display_name: str """ @@ -14515,7 +15545,7 @@ def __init__( subscription_required: Optional[bool] = None, approval_required: Optional[bool] = None, subscriptions_limit: Optional[int] = None, - state: Optional[Union[str, "ProductState"]] = None, + state: Optional[Union[str, "_models.ProductState"]] = None, display_name: Optional[str] = None, **kwargs ): @@ -14544,8 +15574,8 @@ def __init__( :paramtype subscriptions_limit: int :keyword state: whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible only to administrators. Default - state of Product is notPublished. Possible values include: "notPublished", "published". - :paramtype state: str or ~api_management_client.models.ProductState + state of Product is notPublished. Known values are: "notPublished", "published". + :paramtype state: str or ~azure.mgmt.apimanagement.models.ProductState :keyword display_name: Product name. :paramtype display_name: str """ @@ -14586,8 +15616,8 @@ class ProductEntityBaseParameters(msrest.serialization.Model): :vartype subscriptions_limit: int :ivar state: whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible only to administrators. Default state - of Product is notPublished. Possible values include: "notPublished", "published". - :vartype state: str or ~api_management_client.models.ProductState + of Product is notPublished. Known values are: "notPublished", "published". + :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState """ _validation = { @@ -14611,7 +15641,7 @@ def __init__( subscription_required: Optional[bool] = None, approval_required: Optional[bool] = None, subscriptions_limit: Optional[int] = None, - state: Optional[Union[str, "ProductState"]] = None, + state: Optional[Union[str, "_models.ProductState"]] = None, **kwargs ): """ @@ -14639,8 +15669,8 @@ def __init__( :paramtype subscriptions_limit: int :keyword state: whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible only to administrators. Default - state of Product is notPublished. Possible values include: "notPublished", "published". - :paramtype state: str or ~api_management_client.models.ProductState + state of Product is notPublished. Known values are: "notPublished", "published". + :paramtype state: str or ~azure.mgmt.apimanagement.models.ProductState """ super(ProductEntityBaseParameters, self).__init__(**kwargs) self.description = description @@ -14680,8 +15710,8 @@ class ProductContractProperties(ProductEntityBaseParameters): :vartype subscriptions_limit: int :ivar state: whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible only to administrators. Default state - of Product is notPublished. Possible values include: "notPublished", "published". - :vartype state: str or ~api_management_client.models.ProductState + of Product is notPublished. Known values are: "notPublished", "published". + :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState :ivar display_name: Required. Product name. :vartype display_name: str """ @@ -14710,7 +15740,7 @@ def __init__( subscription_required: Optional[bool] = None, approval_required: Optional[bool] = None, subscriptions_limit: Optional[int] = None, - state: Optional[Union[str, "ProductState"]] = None, + state: Optional[Union[str, "_models.ProductState"]] = None, **kwargs ): """ @@ -14738,8 +15768,8 @@ def __init__( :paramtype subscriptions_limit: int :keyword state: whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible only to administrators. Default - state of Product is notPublished. Possible values include: "notPublished", "published". - :paramtype state: str or ~api_management_client.models.ProductState + state of Product is notPublished. Known values are: "notPublished", "published". + :paramtype state: str or ~azure.mgmt.apimanagement.models.ProductState :keyword display_name: Required. Product name. :paramtype display_name: str """ @@ -14776,8 +15806,8 @@ class ProductTagResourceContractProperties(ProductEntityBaseParameters): :vartype subscriptions_limit: int :ivar state: whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible only to administrators. Default state - of Product is notPublished. Possible values include: "notPublished", "published". - :vartype state: str or ~api_management_client.models.ProductState + of Product is notPublished. Known values are: "notPublished", "published". + :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState :ivar id: Identifier of the product in the form of /products/{productId}. :vartype id: str :ivar name: Required. Product name. @@ -14809,7 +15839,7 @@ def __init__( subscription_required: Optional[bool] = None, approval_required: Optional[bool] = None, subscriptions_limit: Optional[int] = None, - state: Optional[Union[str, "ProductState"]] = None, + state: Optional[Union[str, "_models.ProductState"]] = None, id: Optional[str] = None, **kwargs ): @@ -14838,8 +15868,8 @@ def __init__( :paramtype subscriptions_limit: int :keyword state: whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible only to administrators. Default - state of Product is notPublished. Possible values include: "notPublished", "published". - :paramtype state: str or ~api_management_client.models.ProductState + state of Product is notPublished. Known values are: "notPublished", "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. @@ -14877,8 +15907,8 @@ class ProductUpdateParameters(msrest.serialization.Model): :vartype subscriptions_limit: int :ivar state: whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible only to administrators. Default state - of Product is notPublished. Possible values include: "notPublished", "published". - :vartype state: str or ~api_management_client.models.ProductState + of Product is notPublished. Known values are: "notPublished", "published". + :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState :ivar display_name: Product name. :vartype display_name: str """ @@ -14906,7 +15936,7 @@ def __init__( subscription_required: Optional[bool] = None, approval_required: Optional[bool] = None, subscriptions_limit: Optional[int] = None, - state: Optional[Union[str, "ProductState"]] = None, + state: Optional[Union[str, "_models.ProductState"]] = None, display_name: Optional[str] = None, **kwargs ): @@ -14935,8 +15965,8 @@ def __init__( :paramtype subscriptions_limit: int :keyword state: whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible only to administrators. Default - state of Product is notPublished. Possible values include: "notPublished", "published". - :paramtype state: str or ~api_management_client.models.ProductState + state of Product is notPublished. Known values are: "notPublished", "published". + :paramtype state: str or ~azure.mgmt.apimanagement.models.ProductState :keyword display_name: Product name. :paramtype display_name: str """ @@ -14977,8 +16007,8 @@ class ProductUpdateProperties(ProductEntityBaseParameters): :vartype subscriptions_limit: int :ivar state: whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible only to administrators. Default state - of Product is notPublished. Possible values include: "notPublished", "published". - :vartype state: str or ~api_management_client.models.ProductState + of Product is notPublished. Known values are: "notPublished", "published". + :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState :ivar display_name: Product name. :vartype display_name: str """ @@ -15006,7 +16036,7 @@ def __init__( subscription_required: Optional[bool] = None, approval_required: Optional[bool] = None, subscriptions_limit: Optional[int] = None, - state: Optional[Union[str, "ProductState"]] = None, + state: Optional[Union[str, "_models.ProductState"]] = None, display_name: Optional[str] = None, **kwargs ): @@ -15035,8 +16065,8 @@ def __init__( :paramtype subscriptions_limit: int :keyword state: whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible only to administrators. Default - state of Product is notPublished. Possible values include: "notPublished", "published". - :paramtype state: str or ~api_management_client.models.ProductState + state of Product is notPublished. Known values are: "notPublished", "published". + :paramtype state: str or ~azure.mgmt.apimanagement.models.ProductState :keyword display_name: Product name. :paramtype display_name: str """ @@ -15048,7 +16078,7 @@ class QuotaCounterCollection(msrest.serialization.Model): """Paged Quota Counter list representation. :ivar value: Quota counter values. - :vartype value: list[~api_management_client.models.QuotaCounterContract] + :vartype value: list[~azure.mgmt.apimanagement.models.QuotaCounterContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -15064,14 +16094,14 @@ class QuotaCounterCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["QuotaCounterContract"]] = None, + value: Optional[List["_models.QuotaCounterContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Quota counter values. - :paramtype value: list[~api_management_client.models.QuotaCounterContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.QuotaCounterContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -15100,7 +16130,7 @@ class QuotaCounterContract(msrest.serialization.Model): the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. :vartype period_end_time: ~datetime.datetime :ivar value: Quota Value Properties. - :vartype value: ~api_management_client.models.QuotaCounterValueContractProperties + :vartype value: ~azure.mgmt.apimanagement.models.QuotaCounterValueContractProperties """ _validation = { @@ -15125,7 +16155,7 @@ def __init__( period_key: str, period_start_time: datetime.datetime, period_end_time: datetime.datetime, - value: Optional["QuotaCounterValueContractProperties"] = None, + value: Optional["_models.QuotaCounterValueContractProperties"] = None, **kwargs ): """ @@ -15142,7 +16172,7 @@ def __init__( 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: ~api_management_client.models.QuotaCounterValueContractProperties + :paramtype value: ~azure.mgmt.apimanagement.models.QuotaCounterValueContractProperties """ super(QuotaCounterContract, self).__init__(**kwargs) self.counter_key = counter_key @@ -15252,7 +16282,7 @@ class RecipientEmailCollection(msrest.serialization.Model): """Paged Recipient User list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.RecipientEmailContract] + :vartype value: list[~azure.mgmt.apimanagement.models.RecipientEmailContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -15268,14 +16298,14 @@ class RecipientEmailCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RecipientEmailContract"]] = None, + value: Optional[List["_models.RecipientEmailContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.RecipientEmailContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.RecipientEmailContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -15367,7 +16397,7 @@ class RecipientUserCollection(msrest.serialization.Model): """Paged Recipient User list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.RecipientUserContract] + :vartype value: list[~azure.mgmt.apimanagement.models.RecipientUserContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -15383,14 +16413,14 @@ class RecipientUserCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RecipientUserContract"]] = None, + value: Optional[List["_models.RecipientUserContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.RecipientUserContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.RecipientUserContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -15492,7 +16522,7 @@ class RegionListResult(msrest.serialization.Model): """Lists Regions operation response details. :ivar value: Lists of Regions. - :vartype value: list[~api_management_client.models.RegionContract] + :vartype value: list[~azure.mgmt.apimanagement.models.RegionContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -15508,14 +16538,14 @@ class RegionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RegionContract"]] = None, + value: Optional[List["_models.RegionContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Lists of Regions. - :paramtype value: list[~api_management_client.models.RegionContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.RegionContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -15564,11 +16594,11 @@ class RemotePrivateEndpointConnectionWrapper(msrest.serialization.Model): :ivar type: Private Endpoint Connection Resource Type. :vartype type: str :ivar private_endpoint: The resource of private end point. - :vartype private_endpoint: ~api_management_client.models.ArmIdWrapper + :vartype private_endpoint: ~azure.mgmt.apimanagement.models.ArmIdWrapper :ivar private_link_service_connection_state: A collection of information about the state of the connection between service consumer and provider. :vartype private_link_service_connection_state: - ~api_management_client.models.PrivateLinkServiceConnectionState + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. :vartype provisioning_state: str :ivar group_ids: All the Group ids. @@ -15596,8 +16626,8 @@ def __init__( 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, + private_endpoint: Optional["_models.ArmIdWrapper"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -15608,11 +16638,11 @@ def __init__( :keyword type: Private Endpoint Connection Resource Type. :paramtype type: str :keyword private_endpoint: The resource of private end point. - :paramtype private_endpoint: ~api_management_client.models.ArmIdWrapper + :paramtype private_endpoint: ~azure.mgmt.apimanagement.models.ArmIdWrapper :keyword private_link_service_connection_state: A collection of information about the state of the connection between service consumer and provider. :paramtype private_link_service_connection_state: - ~api_management_client.models.PrivateLinkServiceConnectionState + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState """ super(RemotePrivateEndpointConnectionWrapper, self).__init__(**kwargs) self.id = id @@ -15628,7 +16658,7 @@ class ReportCollection(msrest.serialization.Model): """Paged Report records list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.ReportRecordContract] + :vartype value: list[~azure.mgmt.apimanagement.models.ReportRecordContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -15644,14 +16674,14 @@ class ReportCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ReportRecordContract"]] = None, + value: Optional[List["_models.ReportRecordContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.ReportRecordContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.ReportRecordContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -15898,9 +16928,9 @@ class RepresentationContract(msrest.serialization.Model): :vartype type_name: str :ivar form_parameters: Collection of form parameters. Required if 'contentType' value is either 'application/x-www-form-urlencoded' or 'multipart/form-data'.. - :vartype form_parameters: list[~api_management_client.models.ParameterContract] + :vartype form_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :ivar examples: Exampled defined for the representation. - :vartype examples: dict[str, ~api_management_client.models.ParameterExampleContract] + :vartype examples: dict[str, ~azure.mgmt.apimanagement.models.ParameterExampleContract] """ _validation = { @@ -15921,8 +16951,8 @@ def __init__( content_type: str, schema_id: Optional[str] = None, type_name: Optional[str] = None, - form_parameters: Optional[List["ParameterContract"]] = None, - examples: Optional[Dict[str, "ParameterExampleContract"]] = None, + form_parameters: Optional[List["_models.ParameterContract"]] = None, + examples: Optional[Dict[str, "_models.ParameterExampleContract"]] = None, **kwargs ): """ @@ -15937,9 +16967,9 @@ def __init__( :paramtype type_name: str :keyword form_parameters: Collection of form parameters. Required if 'contentType' value is either 'application/x-www-form-urlencoded' or 'multipart/form-data'.. - :paramtype form_parameters: list[~api_management_client.models.ParameterContract] + :paramtype form_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :keyword examples: Exampled defined for the representation. - :paramtype examples: dict[str, ~api_management_client.models.ParameterExampleContract] + :paramtype examples: dict[str, ~azure.mgmt.apimanagement.models.ParameterExampleContract] """ super(RepresentationContract, self).__init__(**kwargs) self.content_type = content_type @@ -15955,11 +16985,11 @@ class RequestContract(msrest.serialization.Model): :ivar description: Operation request description. :vartype description: str :ivar query_parameters: Collection of operation request query parameters. - :vartype query_parameters: list[~api_management_client.models.ParameterContract] + :vartype query_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :ivar headers: Collection of operation request headers. - :vartype headers: list[~api_management_client.models.ParameterContract] + :vartype headers: list[~azure.mgmt.apimanagement.models.ParameterContract] :ivar representations: Collection of operation request representations. - :vartype representations: list[~api_management_client.models.RepresentationContract] + :vartype representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] """ _attribute_map = { @@ -15973,20 +17003,20 @@ def __init__( self, *, description: Optional[str] = None, - query_parameters: Optional[List["ParameterContract"]] = None, - headers: Optional[List["ParameterContract"]] = None, - representations: Optional[List["RepresentationContract"]] = None, + query_parameters: Optional[List["_models.ParameterContract"]] = None, + headers: Optional[List["_models.ParameterContract"]] = None, + representations: Optional[List["_models.RepresentationContract"]] = None, **kwargs ): """ :keyword description: Operation request description. :paramtype description: str :keyword query_parameters: Collection of operation request query parameters. - :paramtype query_parameters: list[~api_management_client.models.ParameterContract] + :paramtype query_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :keyword headers: Collection of operation request headers. - :paramtype headers: list[~api_management_client.models.ParameterContract] + :paramtype headers: list[~azure.mgmt.apimanagement.models.ParameterContract] :keyword representations: Collection of operation request representations. - :paramtype representations: list[~api_management_client.models.RepresentationContract] + :paramtype representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] """ super(RequestContract, self).__init__(**kwargs) self.description = description @@ -15999,7 +17029,7 @@ class RequestReportCollection(msrest.serialization.Model): """Paged Report records list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.RequestReportRecordContract] + :vartype value: list[~azure.mgmt.apimanagement.models.RequestReportRecordContract] :ivar count: Total record count number across all pages. :vartype count: long """ @@ -16012,13 +17042,13 @@ class RequestReportCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RequestReportRecordContract"]] = None, + value: Optional[List["_models.RequestReportRecordContract"]] = None, count: Optional[int] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.RequestReportRecordContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.RequestReportRecordContract] :keyword count: Total record count number across all pages. :paramtype count: long """ @@ -16184,6 +17214,81 @@ def __init__( self.request_size = request_size +class ResourceCollection(msrest.serialization.Model): + """A collection of resources. + + :ivar value: A collection of resources. + :vartype value: list[~azure.mgmt.apimanagement.models.ResourceCollectionValueItem] + :ivar count: Total record count number. + :vartype count: long + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceCollectionValueItem]'}, + 'count': {'key': 'count', 'type': 'long'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ResourceCollectionValueItem"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: A collection of resources. + :paramtype value: list[~azure.mgmt.apimanagement.models.ResourceCollectionValueItem] + :keyword count: Total record count number. + :paramtype count: long + :keyword next_link: Next page link if any. + :paramtype next_link: str + """ + super(ResourceCollection, self).__init__(**kwargs) + self.value = value + self.count = count + self.next_link = next_link + + +class ResourceCollectionValueItem(Resource): + """ResourceCollectionValueItem. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ResourceCollectionValueItem, self).__init__(**kwargs) + + class ResourceLocationDataContract(msrest.serialization.Model): """Resource location data properties. @@ -16242,9 +17347,9 @@ def __init__( class ResourceSku(msrest.serialization.Model): """Describes an available API Management SKU. - :ivar name: Name of the Sku. Possible values include: "Developer", "Standard", "Premium", - "Basic", "Consumption", "Isolated". - :vartype name: str or ~api_management_client.models.SkuType + :ivar name: Name of the Sku. Known values are: "Developer", "Standard", "Premium", "Basic", + "Consumption", "Isolated". + :vartype name: str or ~azure.mgmt.apimanagement.models.SkuType """ _attribute_map = { @@ -16254,13 +17359,13 @@ class ResourceSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "SkuType"]] = None, + name: Optional[Union[str, "_models.SkuType"]] = None, **kwargs ): """ - :keyword name: Name of the Sku. Possible values include: "Developer", "Standard", "Premium", - "Basic", "Consumption", "Isolated". - :paramtype name: str or ~api_management_client.models.SkuType + :keyword name: Name of the Sku. Known values are: "Developer", "Standard", "Premium", "Basic", + "Consumption", "Isolated". + :paramtype name: str or ~azure.mgmt.apimanagement.models.SkuType """ super(ResourceSku, self).__init__(**kwargs) self.name = name @@ -16277,9 +17382,9 @@ class ResourceSkuCapacity(msrest.serialization.Model): :vartype maximum: int :ivar default: The default capacity. :vartype default: int - :ivar scale_type: The scale type applicable to the sku. Possible values include: "automatic", + :ivar scale_type: The scale type applicable to the sku. Known values are: "automatic", "manual", "none". - :vartype scale_type: str or ~api_management_client.models.ResourceSkuCapacityScaleType + :vartype scale_type: str or ~azure.mgmt.apimanagement.models.ResourceSkuCapacityScaleType """ _validation = { @@ -16317,9 +17422,9 @@ class ResourceSkuResult(msrest.serialization.Model): :ivar resource_type: The type of resource the SKU applies to. :vartype resource_type: str :ivar sku: Specifies API Management SKU. - :vartype sku: ~api_management_client.models.ResourceSku + :vartype sku: ~azure.mgmt.apimanagement.models.ResourceSku :ivar capacity: Specifies the number of API Management units. - :vartype capacity: ~api_management_client.models.ResourceSkuCapacity + :vartype capacity: ~azure.mgmt.apimanagement.models.ResourceSkuCapacity """ _validation = { @@ -16352,7 +17457,7 @@ class ResourceSkuResults(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar value: Required. The list of skus available for the service. - :vartype value: list[~api_management_client.models.ResourceSkuResult] + :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 """ @@ -16369,13 +17474,13 @@ class ResourceSkuResults(msrest.serialization.Model): def __init__( self, *, - value: List["ResourceSkuResult"], + value: List["_models.ResourceSkuResult"], next_link: Optional[str] = None, **kwargs ): """ :keyword value: Required. The list of skus available for the service. - :paramtype value: list[~api_management_client.models.ResourceSkuResult] + :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 """ @@ -16394,9 +17499,9 @@ class ResponseContract(msrest.serialization.Model): :ivar description: Operation response description. :vartype description: str :ivar representations: Collection of operation response representations. - :vartype representations: list[~api_management_client.models.RepresentationContract] + :vartype representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] :ivar headers: Collection of operation response headers. - :vartype headers: list[~api_management_client.models.ParameterContract] + :vartype headers: list[~azure.mgmt.apimanagement.models.ParameterContract] """ _validation = { @@ -16415,8 +17520,8 @@ def __init__( *, status_code: int, description: Optional[str] = None, - representations: Optional[List["RepresentationContract"]] = None, - headers: Optional[List["ParameterContract"]] = None, + representations: Optional[List["_models.RepresentationContract"]] = None, + headers: Optional[List["_models.ParameterContract"]] = None, **kwargs ): """ @@ -16425,9 +17530,9 @@ def __init__( :keyword description: Operation response description. :paramtype description: str :keyword representations: Collection of operation response representations. - :paramtype representations: list[~api_management_client.models.RepresentationContract] + :paramtype representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] :keyword headers: Collection of operation response headers. - :paramtype headers: list[~api_management_client.models.ParameterContract] + :paramtype headers: list[~azure.mgmt.apimanagement.models.ParameterContract] """ super(ResponseContract, self).__init__(**kwargs) self.status_code = status_code @@ -16439,8 +17544,8 @@ def __init__( class SamplingSettings(msrest.serialization.Model): """Sampling settings for Diagnostic. - :ivar sampling_type: Sampling type. Possible values include: "fixed". - :vartype sampling_type: str or ~api_management_client.models.SamplingType + :ivar sampling_type: Sampling type. Known values are: "fixed". + :vartype sampling_type: str or ~azure.mgmt.apimanagement.models.SamplingType :ivar percentage: Rate of sampling for fixed-rate sampling. :vartype percentage: float """ @@ -16457,13 +17562,13 @@ class SamplingSettings(msrest.serialization.Model): def __init__( self, *, - sampling_type: Optional[Union[str, "SamplingType"]] = None, + sampling_type: Optional[Union[str, "_models.SamplingType"]] = None, percentage: Optional[float] = None, **kwargs ): """ - :keyword sampling_type: Sampling type. Possible values include: "fixed". - :paramtype sampling_type: str or ~api_management_client.models.SamplingType + :keyword sampling_type: Sampling type. Known values are: "fixed". + :paramtype sampling_type: str or ~azure.mgmt.apimanagement.models.SamplingType :keyword percentage: Rate of sampling for fixed-rate sampling. :paramtype percentage: float """ @@ -16513,7 +17618,7 @@ 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. - :vartype value: list[~api_management_client.models.SchemaContract] + :vartype value: list[~azure.mgmt.apimanagement.models.SchemaContract] :ivar count: Total record count number. :vartype count: long :ivar next_link: Next page link if any. @@ -16631,7 +17736,7 @@ class SubscriptionCollection(msrest.serialization.Model): """Paged Subscriptions list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.SubscriptionContract] + :vartype value: list[~azure.mgmt.apimanagement.models.SubscriptionContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -16647,14 +17752,14 @@ class SubscriptionCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["SubscriptionContract"]] = None, + value: Optional[List["_models.SubscriptionContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.SubscriptionContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.SubscriptionContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -16692,9 +17797,8 @@ class SubscriptionContract(Resource): been approved or rejected, * rejected – the subscription request has been denied by an administrator, * cancelled – the subscription has been cancelled by the developer or administrator, * expired – the subscription reached its expiration date and was deactivated. - Possible values include: "suspended", "active", "expired", "submitted", "rejected", - "cancelled". - :vartype state: str or ~api_management_client.models.SubscriptionState + Known values are: "suspended", "active", "expired", "submitted", "rejected", "cancelled". + :vartype state: str or ~azure.mgmt.apimanagement.models.SubscriptionState :ivar created_date: Subscription creation date. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. :vartype created_date: ~datetime.datetime @@ -16764,7 +17868,7 @@ def __init__( owner_id: Optional[str] = None, scope: Optional[str] = None, display_name: Optional[str] = None, - state: Optional[Union[str, "SubscriptionState"]] = None, + state: Optional[Union[str, "_models.SubscriptionState"]] = None, start_date: Optional[datetime.datetime] = None, expiration_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, @@ -16789,9 +17893,8 @@ def __init__( been approved or rejected, * rejected – the subscription request has been denied by an administrator, * cancelled – the subscription has been cancelled by the developer or administrator, * expired – the subscription reached its expiration date and was deactivated. - Possible values include: "suspended", "active", "expired", "submitted", "rejected", - "cancelled". - :paramtype state: str or ~api_management_client.models.SubscriptionState + Known values are: "suspended", "active", "expired", "submitted", "rejected", "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: @@ -16861,9 +17964,9 @@ class SubscriptionCreateParameters(msrest.serialization.Model): the subscription request has been made by the developer, but has not yet been approved or rejected, * rejected – the subscription request has been denied by an administrator, * cancelled – the subscription has been cancelled by the developer or administrator, * expired – - the subscription reached its expiration date and was deactivated. Possible values include: + the subscription reached its expiration date and was deactivated. Known values are: "suspended", "active", "expired", "submitted", "rejected", "cancelled". - :vartype state: str or ~api_management_client.models.SubscriptionState + :vartype state: str or ~azure.mgmt.apimanagement.models.SubscriptionState :ivar allow_tracing: Determines whether tracing can be enabled. :vartype allow_tracing: bool """ @@ -16892,7 +17995,7 @@ def __init__( display_name: Optional[str] = None, primary_key: Optional[str] = None, secondary_key: Optional[str] = None, - state: Optional[Union[str, "SubscriptionState"]] = None, + state: Optional[Union[str, "_models.SubscriptionState"]] = None, allow_tracing: Optional[bool] = None, **kwargs ): @@ -16917,9 +18020,8 @@ def __init__( approved or rejected, * rejected – the subscription request has been denied by an administrator, * cancelled – the subscription has been cancelled by the developer or administrator, * expired – the subscription reached its expiration date and was deactivated. - Possible values include: "suspended", "active", "expired", "submitted", "rejected", - "cancelled". - :paramtype state: str or ~api_management_client.models.SubscriptionState + Known values are: "suspended", "active", "expired", "submitted", "rejected", "cancelled". + :paramtype state: str or ~azure.mgmt.apimanagement.models.SubscriptionState :keyword allow_tracing: Determines whether tracing can be enabled. :paramtype allow_tracing: bool """ @@ -17051,9 +18153,8 @@ class SubscriptionUpdateParameters(msrest.serialization.Model): been approved or rejected, * rejected – the subscription request has been denied by an administrator, * cancelled – the subscription has been cancelled by the developer or administrator, * expired – the subscription reached its expiration date and was deactivated. - Possible values include: "suspended", "active", "expired", "submitted", "rejected", - "cancelled". - :vartype state: str or ~api_management_client.models.SubscriptionState + Known values are: "suspended", "active", "expired", "submitted", "rejected", "cancelled". + :vartype state: str or ~azure.mgmt.apimanagement.models.SubscriptionState :ivar state_comment: Comments describing subscription state change by the administrator when the state is changed to the 'rejected'. :vartype state_comment: str @@ -17087,7 +18188,7 @@ def __init__( display_name: Optional[str] = None, primary_key: Optional[str] = None, secondary_key: Optional[str] = None, - state: Optional[Union[str, "SubscriptionState"]] = None, + state: Optional[Union[str, "_models.SubscriptionState"]] = None, state_comment: Optional[str] = None, allow_tracing: Optional[bool] = None, **kwargs @@ -17114,9 +18215,8 @@ def __init__( been approved or rejected, * rejected – the subscription request has been denied by an administrator, * cancelled – the subscription has been cancelled by the developer or administrator, * expired – the subscription reached its expiration date and was deactivated. - Possible values include: "suspended", "active", "expired", "submitted", "rejected", - "cancelled". - :paramtype state: str or ~api_management_client.models.SubscriptionState + Known values are: "suspended", "active", "expired", "submitted", "rejected", "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 @@ -17140,16 +18240,16 @@ class SystemData(msrest.serialization.Model): :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: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". - :vartype created_by_type: str or ~api_management_client.models.CreatedByType + :vartype created_by_type: str or ~azure.mgmt.apimanagement.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :vartype last_modified_by_type: str or ~api_management_client.models.CreatedByType + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "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 """ @@ -17167,26 +18267,26 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :paramtype created_by_type: str or ~api_management_client.models.CreatedByType + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.apimanagement.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :paramtype last_modified_by_type: str or ~api_management_client.models.CreatedByType + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "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 """ @@ -17203,7 +18303,7 @@ class TagCollection(msrest.serialization.Model): """Paged Tag list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.TagContract] + :vartype value: list[~azure.mgmt.apimanagement.models.TagContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -17219,14 +18319,14 @@ class TagCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["TagContract"]] = None, + value: Optional[List["_models.TagContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.TagContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.TagContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -17359,7 +18459,7 @@ class TagDescriptionCollection(msrest.serialization.Model): """Paged TagDescription list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.TagDescriptionContract] + :vartype value: list[~azure.mgmt.apimanagement.models.TagDescriptionContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -17375,14 +18475,14 @@ class TagDescriptionCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["TagDescriptionContract"]] = None, + value: Optional[List["_models.TagDescriptionContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.TagDescriptionContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.TagDescriptionContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -17570,7 +18670,7 @@ class TagResourceCollection(msrest.serialization.Model): """Paged Tag list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.TagResourceContract] + :vartype value: list[~azure.mgmt.apimanagement.models.TagResourceContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -17586,14 +18686,14 @@ class TagResourceCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["TagResourceContract"]] = None, + value: Optional[List["_models.TagResourceContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.TagResourceContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.TagResourceContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -17611,13 +18711,13 @@ class TagResourceContract(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar tag: Required. Tag associated with the resource. - :vartype tag: ~api_management_client.models.TagResourceContractProperties + :vartype tag: ~azure.mgmt.apimanagement.models.TagResourceContractProperties :ivar api: API associated with the tag. - :vartype api: ~api_management_client.models.ApiTagResourceContractProperties + :vartype api: ~azure.mgmt.apimanagement.models.ApiTagResourceContractProperties :ivar operation: Operation associated with the tag. - :vartype operation: ~api_management_client.models.OperationTagResourceContractProperties + :vartype operation: ~azure.mgmt.apimanagement.models.OperationTagResourceContractProperties :ivar product: Product associated with the tag. - :vartype product: ~api_management_client.models.ProductTagResourceContractProperties + :vartype product: ~azure.mgmt.apimanagement.models.ProductTagResourceContractProperties """ _validation = { @@ -17634,21 +18734,21 @@ class TagResourceContract(msrest.serialization.Model): def __init__( self, *, - tag: "TagResourceContractProperties", - api: Optional["ApiTagResourceContractProperties"] = None, - operation: Optional["OperationTagResourceContractProperties"] = None, - product: Optional["ProductTagResourceContractProperties"] = None, + tag: "_models.TagResourceContractProperties", + api: Optional["_models.ApiTagResourceContractProperties"] = None, + operation: Optional["_models.OperationTagResourceContractProperties"] = None, + product: Optional["_models.ProductTagResourceContractProperties"] = None, **kwargs ): """ :keyword tag: Required. Tag associated with the resource. - :paramtype tag: ~api_management_client.models.TagResourceContractProperties + :paramtype tag: ~azure.mgmt.apimanagement.models.TagResourceContractProperties :keyword api: API associated with the tag. - :paramtype api: ~api_management_client.models.ApiTagResourceContractProperties + :paramtype api: ~azure.mgmt.apimanagement.models.ApiTagResourceContractProperties :keyword operation: Operation associated with the tag. - :paramtype operation: ~api_management_client.models.OperationTagResourceContractProperties + :paramtype operation: ~azure.mgmt.apimanagement.models.OperationTagResourceContractProperties :keyword product: Product associated with the tag. - :paramtype product: ~api_management_client.models.ProductTagResourceContractProperties + :paramtype product: ~azure.mgmt.apimanagement.models.ProductTagResourceContractProperties """ super(TagResourceContract, self).__init__(**kwargs) self.tag = tag @@ -17799,7 +18899,7 @@ class TenantSettingsCollection(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Page values. - :vartype value: list[~api_management_client.models.TenantSettingsContract] + :vartype value: list[~azure.mgmt.apimanagement.models.TenantSettingsContract] :ivar next_link: Next page link if any. :vartype next_link: str """ @@ -17951,7 +19051,7 @@ class UserCollection(msrest.serialization.Model): """Paged Users list representation. :ivar value: Page values. - :vartype value: list[~api_management_client.models.UserContract] + :vartype value: list[~azure.mgmt.apimanagement.models.UserContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -17967,14 +19067,14 @@ class UserCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["UserContract"]] = None, + value: Optional[List["_models.UserContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Page values. - :paramtype value: list[~api_management_client.models.UserContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.UserContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -18001,13 +19101,13 @@ class UserContract(Resource): :vartype type: str :ivar state: Account state. Specifies whether the user is active or not. Blocked users are unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + is Active. Known values are: "active", "blocked", "pending", "deleted". Default value: "active". - :vartype state: str or ~api_management_client.models.UserState + :vartype state: str or ~azure.mgmt.apimanagement.models.UserState :ivar note: Optional note about a user set by the administrator. :vartype note: str :ivar identities: Collection of user identities. - :vartype identities: list[~api_management_client.models.UserIdentityContract] + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :ivar first_name: First name. :vartype first_name: str :ivar last_name: Last name. @@ -18018,7 +19118,7 @@ class UserContract(Resource): ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. :vartype registration_date: ~datetime.datetime :ivar groups: Collection of groups user is part of. - :vartype groups: list[~api_management_client.models.GroupContractProperties] + :vartype groups: list[~azure.mgmt.apimanagement.models.GroupContractProperties] """ _validation = { @@ -18045,9 +19145,9 @@ class UserContract(Resource): def __init__( self, *, - state: Optional[Union[str, "UserState"]] = "active", + state: Optional[Union[str, "_models.UserState"]] = "active", note: Optional[str] = None, - identities: Optional[List["UserIdentityContract"]] = None, + identities: Optional[List["_models.UserIdentityContract"]] = None, first_name: Optional[str] = None, last_name: Optional[str] = None, email: Optional[str] = None, @@ -18057,13 +19157,13 @@ def __init__( """ :keyword state: Account state. Specifies whether the user is active or not. Blocked users are unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + is Active. Known values are: "active", "blocked", "pending", "deleted". Default value: "active". - :paramtype state: str or ~api_management_client.models.UserState + :paramtype state: str or ~azure.mgmt.apimanagement.models.UserState :keyword note: Optional note about a user set by the administrator. :paramtype note: str :keyword identities: Collection of user identities. - :paramtype identities: list[~api_management_client.models.UserIdentityContract] + :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :keyword first_name: First name. :paramtype first_name: str :keyword last_name: Last name. @@ -18090,13 +19190,13 @@ class UserEntityBaseParameters(msrest.serialization.Model): :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: + is Active. Known values are: "active", "blocked", "pending", "deleted". Default value: "active". - :vartype state: str or ~api_management_client.models.UserState + :vartype state: str or ~azure.mgmt.apimanagement.models.UserState :ivar note: Optional note about a user set by the administrator. :vartype note: str :ivar identities: Collection of user identities. - :vartype identities: list[~api_management_client.models.UserIdentityContract] + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] """ _attribute_map = { @@ -18108,21 +19208,21 @@ class UserEntityBaseParameters(msrest.serialization.Model): def __init__( self, *, - state: Optional[Union[str, "UserState"]] = "active", + state: Optional[Union[str, "_models.UserState"]] = "active", note: Optional[str] = None, - identities: Optional[List["UserIdentityContract"]] = None, + identities: Optional[List["_models.UserIdentityContract"]] = None, **kwargs ): """ :keyword state: Account state. Specifies whether the user is active or not. Blocked users are unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + is Active. Known values are: "active", "blocked", "pending", "deleted". Default value: "active". - :paramtype state: str or ~api_management_client.models.UserState + :paramtype state: str or ~azure.mgmt.apimanagement.models.UserState :keyword note: Optional note about a user set by the administrator. :paramtype note: str :keyword identities: Collection of user identities. - :paramtype identities: list[~api_management_client.models.UserIdentityContract] + :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] """ super(UserEntityBaseParameters, self).__init__(**kwargs) self.state = state @@ -18137,13 +19237,13 @@ class UserContractProperties(UserEntityBaseParameters): :ivar state: Account state. Specifies whether the user is active or not. Blocked users are unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + is Active. Known values are: "active", "blocked", "pending", "deleted". Default value: "active". - :vartype state: str or ~api_management_client.models.UserState + :vartype state: str or ~azure.mgmt.apimanagement.models.UserState :ivar note: Optional note about a user set by the administrator. :vartype note: str :ivar identities: Collection of user identities. - :vartype identities: list[~api_management_client.models.UserIdentityContract] + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :ivar first_name: First name. :vartype first_name: str :ivar last_name: Last name. @@ -18154,7 +19254,7 @@ class UserContractProperties(UserEntityBaseParameters): ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. :vartype registration_date: ~datetime.datetime :ivar groups: Collection of groups user is part of. - :vartype groups: list[~api_management_client.models.GroupContractProperties] + :vartype groups: list[~azure.mgmt.apimanagement.models.GroupContractProperties] """ _validation = { @@ -18175,9 +19275,9 @@ class UserContractProperties(UserEntityBaseParameters): def __init__( self, *, - state: Optional[Union[str, "UserState"]] = "active", + state: Optional[Union[str, "_models.UserState"]] = "active", note: Optional[str] = None, - identities: Optional[List["UserIdentityContract"]] = None, + identities: Optional[List["_models.UserIdentityContract"]] = None, first_name: Optional[str] = None, last_name: Optional[str] = None, email: Optional[str] = None, @@ -18187,13 +19287,13 @@ def __init__( """ :keyword state: Account state. Specifies whether the user is active or not. Blocked users are unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + is Active. Known values are: "active", "blocked", "pending", "deleted". Default value: "active". - :paramtype state: str or ~api_management_client.models.UserState + :paramtype state: str or ~azure.mgmt.apimanagement.models.UserState :keyword note: Optional note about a user set by the administrator. :paramtype note: str :keyword identities: Collection of user identities. - :paramtype identities: list[~api_management_client.models.UserIdentityContract] + :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :keyword first_name: First name. :paramtype first_name: str :keyword last_name: Last name. @@ -18219,13 +19319,13 @@ class UserCreateParameterProperties(UserEntityBaseParameters): :ivar state: Account state. Specifies whether the user is active or not. Blocked users are unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + is Active. Known values are: "active", "blocked", "pending", "deleted". Default value: "active". - :vartype state: str or ~api_management_client.models.UserState + :vartype state: str or ~azure.mgmt.apimanagement.models.UserState :ivar note: Optional note about a user set by the administrator. :vartype note: str :ivar identities: Collection of user identities. - :vartype identities: list[~api_management_client.models.UserIdentityContract] + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :ivar email: Required. Email address. Must not be empty and must be unique within the service instance. :vartype email: str @@ -18236,11 +19336,11 @@ class UserCreateParameterProperties(UserEntityBaseParameters): :ivar password: User Password. If no value is provided, a default password is generated. :vartype password: str :ivar app_type: Determines the type of application which send the create user request. Default - is legacy portal. Possible values include: "portal", "developerPortal". - :vartype app_type: str or ~api_management_client.models.AppType + is legacy portal. Known values are: "portal", "developerPortal". + :vartype app_type: str or ~azure.mgmt.apimanagement.models.AppType :ivar confirmation: Determines the type of confirmation e-mail that will be sent to the newly - created user. Possible values include: "signup", "invite". - :vartype confirmation: str or ~api_management_client.models.Confirmation + created user. Known values are: "signup", "invite". + :vartype confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation """ _validation = { @@ -18267,24 +19367,24 @@ def __init__( email: str, first_name: str, last_name: str, - state: Optional[Union[str, "UserState"]] = "active", + state: Optional[Union[str, "_models.UserState"]] = "active", note: Optional[str] = None, - identities: Optional[List["UserIdentityContract"]] = None, + identities: Optional[List["_models.UserIdentityContract"]] = None, password: Optional[str] = None, - app_type: Optional[Union[str, "AppType"]] = None, - confirmation: Optional[Union[str, "Confirmation"]] = None, + app_type: Optional[Union[str, "_models.AppType"]] = None, + confirmation: Optional[Union[str, "_models.Confirmation"]] = None, **kwargs ): """ :keyword state: Account state. Specifies whether the user is active or not. Blocked users are unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + is Active. Known values are: "active", "blocked", "pending", "deleted". Default value: "active". - :paramtype state: str or ~api_management_client.models.UserState + :paramtype state: str or ~azure.mgmt.apimanagement.models.UserState :keyword note: Optional note about a user set by the administrator. :paramtype note: str :keyword identities: Collection of user identities. - :paramtype identities: list[~api_management_client.models.UserIdentityContract] + :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :keyword email: Required. Email address. Must not be empty and must be unique within the service instance. :paramtype email: str @@ -18295,11 +19395,11 @@ def __init__( :keyword password: User Password. If no value is provided, a default password is generated. :paramtype password: str :keyword app_type: Determines the type of application which send the create user request. - Default is legacy portal. Possible values include: "portal", "developerPortal". - :paramtype app_type: str or ~api_management_client.models.AppType + Default is legacy portal. Known values are: "portal", "developerPortal". + :paramtype app_type: str or ~azure.mgmt.apimanagement.models.AppType :keyword confirmation: Determines the type of confirmation e-mail that will be sent to the - newly created user. Possible values include: "signup", "invite". - :paramtype confirmation: str or ~api_management_client.models.Confirmation + newly created user. Known values are: "signup", "invite". + :paramtype confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation """ super(UserCreateParameterProperties, self).__init__(state=state, note=note, identities=identities, **kwargs) self.email = email @@ -18315,13 +19415,13 @@ class UserCreateParameters(msrest.serialization.Model): :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: + is Active. Known values are: "active", "blocked", "pending", "deleted". Default value: "active". - :vartype state: str or ~api_management_client.models.UserState + :vartype state: str or ~azure.mgmt.apimanagement.models.UserState :ivar note: Optional note about a user set by the administrator. :vartype note: str :ivar identities: Collection of user identities. - :vartype identities: list[~api_management_client.models.UserIdentityContract] + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :ivar email: Email address. Must not be empty and must be unique within the service instance. :vartype email: str :ivar first_name: First name. @@ -18331,11 +19431,11 @@ class UserCreateParameters(msrest.serialization.Model): :ivar password: User Password. If no value is provided, a default password is generated. :vartype password: str :ivar app_type: Determines the type of application which send the create user request. Default - is legacy portal. Possible values include: "portal", "developerPortal". - :vartype app_type: str or ~api_management_client.models.AppType + is legacy portal. Known values are: "portal", "developerPortal". + :vartype app_type: str or ~azure.mgmt.apimanagement.models.AppType :ivar confirmation: Determines the type of confirmation e-mail that will be sent to the newly - created user. Possible values include: "signup", "invite". - :vartype confirmation: str or ~api_management_client.models.Confirmation + created user. Known values are: "signup", "invite". + :vartype confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation """ _validation = { @@ -18359,27 +19459,27 @@ class UserCreateParameters(msrest.serialization.Model): def __init__( self, *, - state: Optional[Union[str, "UserState"]] = "active", + state: Optional[Union[str, "_models.UserState"]] = "active", note: Optional[str] = None, - identities: Optional[List["UserIdentityContract"]] = None, + identities: Optional[List["_models.UserIdentityContract"]] = None, email: Optional[str] = None, first_name: Optional[str] = None, last_name: Optional[str] = None, password: Optional[str] = None, - app_type: Optional[Union[str, "AppType"]] = None, - confirmation: Optional[Union[str, "Confirmation"]] = None, + app_type: Optional[Union[str, "_models.AppType"]] = None, + confirmation: Optional[Union[str, "_models.Confirmation"]] = None, **kwargs ): """ :keyword state: Account state. Specifies whether the user is active or not. Blocked users are unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + is Active. Known values are: "active", "blocked", "pending", "deleted". Default value: "active". - :paramtype state: str or ~api_management_client.models.UserState + :paramtype state: str or ~azure.mgmt.apimanagement.models.UserState :keyword note: Optional note about a user set by the administrator. :paramtype note: str :keyword identities: Collection of user identities. - :paramtype identities: list[~api_management_client.models.UserIdentityContract] + :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :keyword email: Email address. Must not be empty and must be unique within the service instance. :paramtype email: str @@ -18390,11 +19490,11 @@ def __init__( :keyword password: User Password. If no value is provided, a default password is generated. :paramtype password: str :keyword app_type: Determines the type of application which send the create user request. - Default is legacy portal. Possible values include: "portal", "developerPortal". - :paramtype app_type: str or ~api_management_client.models.AppType + Default is legacy portal. Known values are: "portal", "developerPortal". + :paramtype app_type: str or ~azure.mgmt.apimanagement.models.AppType :keyword confirmation: Determines the type of confirmation e-mail that will be sent to the - newly created user. Possible values include: "signup", "invite". - :paramtype confirmation: str or ~api_management_client.models.Confirmation + newly created user. Known values are: "signup", "invite". + :paramtype confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation """ super(UserCreateParameters, self).__init__(**kwargs) self.state = state @@ -18412,7 +19512,7 @@ class UserIdentityCollection(msrest.serialization.Model): """List of Users Identity list representation. :ivar value: User Identity values. - :vartype value: list[~api_management_client.models.UserIdentityContract] + :vartype value: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :ivar count: Total record count number across all pages. :vartype count: long :ivar next_link: Next page link if any. @@ -18428,14 +19528,14 @@ class UserIdentityCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["UserIdentityContract"]] = None, + value: Optional[List["_models.UserIdentityContract"]] = None, count: Optional[int] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: User Identity values. - :paramtype value: list[~api_management_client.models.UserIdentityContract] + :paramtype value: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :keyword count: Total record count number across all pages. :paramtype count: long :keyword next_link: Next page link if any. @@ -18514,9 +19614,9 @@ def __init__( class UserTokenParameters(msrest.serialization.Model): """Get User Token parameters. - :ivar key_type: The Key to be used to generate token for user. Possible values include: - "primary", "secondary". - :vartype key_type: str or ~api_management_client.models.KeyType + :ivar key_type: The Key to be used to generate token for user. Known values are: "primary", + "secondary". + :vartype key_type: str or ~azure.mgmt.apimanagement.models.KeyType :ivar expiry: The Expiry time of the Token. Maximum token expiry time is set to 30 days. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. @@ -18531,14 +19631,14 @@ class UserTokenParameters(msrest.serialization.Model): def __init__( self, *, - key_type: Optional[Union[str, "KeyType"]] = None, + key_type: Optional[Union[str, "_models.KeyType"]] = None, expiry: Optional[datetime.datetime] = None, **kwargs ): """ - :keyword key_type: The Key to be used to generate token for user. Possible values include: - "primary", "secondary". - :paramtype key_type: str or ~api_management_client.models.KeyType + :keyword key_type: The Key to be used to generate token for user. Known values are: "primary", + "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. @@ -18579,13 +19679,13 @@ class UserUpdateParameters(msrest.serialization.Model): :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: + is Active. Known values are: "active", "blocked", "pending", "deleted". Default value: "active". - :vartype state: str or ~api_management_client.models.UserState + :vartype state: str or ~azure.mgmt.apimanagement.models.UserState :ivar note: Optional note about a user set by the administrator. :vartype note: str :ivar identities: Collection of user identities. - :vartype identities: list[~api_management_client.models.UserIdentityContract] + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :ivar email: Email address. Must not be empty and must be unique within the service instance. :vartype email: str :ivar password: User Password. @@ -18615,9 +19715,9 @@ class UserUpdateParameters(msrest.serialization.Model): def __init__( self, *, - state: Optional[Union[str, "UserState"]] = "active", + state: Optional[Union[str, "_models.UserState"]] = "active", note: Optional[str] = None, - identities: Optional[List["UserIdentityContract"]] = None, + identities: Optional[List["_models.UserIdentityContract"]] = None, email: Optional[str] = None, password: Optional[str] = None, first_name: Optional[str] = None, @@ -18627,13 +19727,13 @@ def __init__( """ :keyword state: Account state. Specifies whether the user is active or not. Blocked users are unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + is Active. Known values are: "active", "blocked", "pending", "deleted". Default value: "active". - :paramtype state: str or ~api_management_client.models.UserState + :paramtype state: str or ~azure.mgmt.apimanagement.models.UserState :keyword note: Optional note about a user set by the administrator. :paramtype note: str :keyword identities: Collection of user identities. - :paramtype identities: list[~api_management_client.models.UserIdentityContract] + :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :keyword email: Email address. Must not be empty and must be unique within the service instance. :paramtype email: str @@ -18659,13 +19759,13 @@ class UserUpdateParametersProperties(UserEntityBaseParameters): :ivar state: Account state. Specifies whether the user is active or not. Blocked users are unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + is Active. Known values are: "active", "blocked", "pending", "deleted". Default value: "active". - :vartype state: str or ~api_management_client.models.UserState + :vartype state: str or ~azure.mgmt.apimanagement.models.UserState :ivar note: Optional note about a user set by the administrator. :vartype note: str :ivar identities: Collection of user identities. - :vartype identities: list[~api_management_client.models.UserIdentityContract] + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :ivar email: Email address. Must not be empty and must be unique within the service instance. :vartype email: str :ivar password: User Password. @@ -18695,9 +19795,9 @@ class UserUpdateParametersProperties(UserEntityBaseParameters): def __init__( self, *, - state: Optional[Union[str, "UserState"]] = "active", + state: Optional[Union[str, "_models.UserState"]] = "active", note: Optional[str] = None, - identities: Optional[List["UserIdentityContract"]] = None, + identities: Optional[List["_models.UserIdentityContract"]] = None, email: Optional[str] = None, password: Optional[str] = None, first_name: Optional[str] = None, @@ -18707,13 +19807,13 @@ def __init__( """ :keyword state: Account state. Specifies whether the user is active or not. Blocked users are unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + is Active. Known values are: "active", "blocked", "pending", "deleted". Default value: "active". - :paramtype state: str or ~api_management_client.models.UserState + :paramtype state: str or ~azure.mgmt.apimanagement.models.UserState :keyword note: Optional note about a user set by the administrator. :paramtype note: str :keyword identities: Collection of user identities. - :paramtype identities: list[~api_management_client.models.UserIdentityContract] + :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :keyword email: Email address. Must not be empty and must be unique within the service instance. :paramtype email: str diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_patch.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/__init__.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/__init__.py index 9f8b6482fabb..4d45f11ba059 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 @@ -24,6 +24,10 @@ from ._api_export_operations import ApiExportOperations from ._api_version_set_operations import ApiVersionSetOperations from ._authorization_server_operations import AuthorizationServerOperations +from ._authorization_provider_operations import AuthorizationProviderOperations +from ._authorization_operations import AuthorizationOperations +from ._authorization_login_links_operations import AuthorizationLoginLinksOperations +from ._authorization_access_policy_operations import AuthorizationAccessPolicyOperations from ._backend_operations import BackendOperations from ._cache_operations import CacheOperations from ._certificate_operations import CertificateOperations @@ -54,6 +58,8 @@ from ._outbound_network_dependencies_endpoints_operations import OutboundNetworkDependenciesEndpointsOperations from ._policy_operations import PolicyOperations from ._policy_description_operations import PolicyDescriptionOperations +from ._policy_fragment_operations import PolicyFragmentOperations +from ._portal_config_operations import PortalConfigOperations from ._portal_revision_operations import PortalRevisionOperations from ._portal_settings_operations import PortalSettingsOperations from ._sign_in_settings_operations import SignInSettingsOperations @@ -83,6 +89,9 @@ from ._user_identities_operations import UserIdentitiesOperations from ._user_confirmation_password_operations import UserConfirmationPasswordOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ApiOperations', 'ApiRevisionOperations', @@ -102,6 +111,10 @@ 'ApiExportOperations', 'ApiVersionSetOperations', 'AuthorizationServerOperations', + 'AuthorizationProviderOperations', + 'AuthorizationOperations', + 'AuthorizationLoginLinksOperations', + 'AuthorizationAccessPolicyOperations', 'BackendOperations', 'CacheOperations', 'CertificateOperations', @@ -132,6 +145,8 @@ 'OutboundNetworkDependenciesEndpointsOperations', 'PolicyOperations', 'PolicyDescriptionOperations', + 'PolicyFragmentOperations', + 'PortalConfigOperations', 'PortalRevisionOperations', 'PortalSettingsOperations', 'SignInSettingsOperations', @@ -161,3 +176,5 @@ 'UserIdentitiesOperations', 'UserConfirmationPasswordOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 3dd52b858228..bd2d75d91fed 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_diagnostic_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_diagnostic_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -38,10 +38,14 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -49,27 +53,25 @@ def build_list_by_service_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -82,10 +84,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -94,21 +100,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -121,10 +125,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -133,21 +141,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -159,17 +165,20 @@ def build_create_or_update_request( diagnostic_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DiagnosticContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -178,25 +187,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -211,16 +218,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.DiagnosticContract] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -229,24 +239,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -263,10 +271,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -275,46 +287,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ApiDiagnosticOperations(object): - """ApiDiagnosticOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiDiagnosticOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_diagnostic` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -326,7 +334,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.DiagnosticCollection"]: + ) -> Iterable[_models.DiagnosticCollection]: """Lists all diagnostics of an API. :param resource_group_name: The name of the resource group. @@ -337,23 +345,29 @@ def list_by_service( :type api_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DiagnosticCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.DiagnosticCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.DiagnosticCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -362,13 +376,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -377,13 +394,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -397,7 +417,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -411,7 +435,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics"} # type: ignore @distributed_trace def get_entity_tag( @@ -438,11 +462,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -451,12 +480,19 @@ def get_entity_tag( api_id=api_id, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -472,7 +508,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace @@ -483,7 +519,7 @@ def get( api_id: str, diagnostic_id: str, **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _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. @@ -497,14 +533,19 @@ def get( :type diagnostic_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticContract] request = build_get_request( @@ -513,12 +554,19 @@ def get( api_id=api_id, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -536,7 +584,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace @@ -546,10 +594,10 @@ def create_or_update( service_name: str, api_id: str, diagnostic_id: str, - parameters: "_models.DiagnosticContract", + parameters: _models.DiagnosticContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _models.DiagnosticContract: """Creates a new Diagnostic for an API or updates an existing one. :param resource_group_name: The name of the resource group. @@ -562,22 +610,26 @@ def create_or_update( service instance. :type diagnostic_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.DiagnosticContract + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticContract] _json = self._serialize.body(parameters, 'DiagnosticContract') @@ -587,15 +639,22 @@ def create_or_update( api_id=api_id, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -619,7 +678,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace @@ -630,9 +689,9 @@ def update( api_id: str, diagnostic_id: str, if_match: str, - parameters: "_models.DiagnosticContract", + parameters: _models.DiagnosticContract, **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _models.DiagnosticContract: """Updates the details of the Diagnostic for an API specified by its identifier. :param resource_group_name: The name of the resource group. @@ -648,19 +707,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Diagnostic Update parameters. - :type parameters: ~api_management_client.models.DiagnosticContract + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticContract] _json = self._serialize.body(parameters, 'DiagnosticContract') @@ -670,15 +733,22 @@ def update( api_id=api_id, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -696,11 +766,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -728,11 +798,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -741,13 +816,20 @@ def delete( api_id=api_id, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -758,5 +840,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_export_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_export_operations.py index a357e2989249..8301cd20d65e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_export_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_export_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,20 +6,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 typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -35,10 +36,14 @@ def build_get_request( export: Union[str, "_models.ExportApi"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -46,47 +51,43 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['format'] = _SERIALIZER.query("format", format, 'str') - query_parameters['export'] = _SERIALIZER.query("export", export, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['format'] = _SERIALIZER.query("format", format, 'str') + _params['export'] = _SERIALIZER.query("export", export, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ApiExportOperations(object): - """ApiExportOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiExportOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_export` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -97,7 +98,7 @@ def get( format: Union[str, "_models.ExportFormat"], export: Union[str, "_models.ExportApi"], **kwargs: Any - ) -> "_models.ApiExportResult": + ) -> _models.ApiExportResult: """Gets the details of the API specified by its identifier in the format specified to the Storage Blob with SAS Key valid for 5 minutes. @@ -110,19 +111,24 @@ def get( :type api_id: str :param format: Format in which to export the Api Details to the Storage Blob with Sas Key valid for 5 minutes. - :type format: str or ~api_management_client.models.ExportFormat + :type format: str or ~azure.mgmt.apimanagement.models.ExportFormat :param export: Query parameter required to export the API details. - :type export: str or ~api_management_client.models.ExportApi + :type export: str or ~azure.mgmt.apimanagement.models.ExportApi :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiExportResult, or the result of cls(response) - :rtype: ~api_management_client.models.ApiExportResult + :rtype: ~azure.mgmt.apimanagement.models.ApiExportResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiExportResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiExportResult] request = build_get_request( @@ -130,14 +136,21 @@ def get( service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, format=format, export=export, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -152,5 +165,5 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_attachment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_attachment_operations.py index a8fd53b22ce0..d0a3ac35119a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_attachment_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_attachment_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -39,10 +39,14 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -51,27 +55,25 @@ def build_list_by_service_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -85,10 +87,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -98,21 +104,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -126,10 +130,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -139,21 +147,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -166,17 +172,20 @@ def build_create_or_update_request( attachment_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.IssueAttachmentContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -186,25 +195,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -222,10 +229,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -235,46 +246,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ApiIssueAttachmentOperations(object): - """ApiIssueAttachmentOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiIssueAttachmentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_issue_attachment` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -287,7 +294,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.IssueAttachmentCollection"]: + ) -> Iterable[_models.IssueAttachmentCollection]: """Lists all attachments for the Issue associated with the specified API. :param resource_group_name: The name of the resource group. @@ -302,23 +309,30 @@ def list_by_service( :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either IssueAttachmentCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.IssueAttachmentCollection] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IssueAttachmentCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueAttachmentCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueAttachmentCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -328,13 +342,16 @@ def prepare_request(next_link=None): api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -344,13 +361,16 @@ def prepare_request(next_link=None): api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -364,7 +384,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -378,7 +402,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments"} # type: ignore @distributed_trace def get_entity_tag( @@ -410,11 +434,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -424,12 +453,19 @@ def get_entity_tag( issue_id=issue_id, attachment_id=attachment_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -445,7 +481,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}"} # type: ignore @distributed_trace @@ -457,7 +493,7 @@ def get( issue_id: str, attachment_id: str, **kwargs: Any - ) -> "_models.IssueAttachmentContract": + ) -> _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. @@ -474,14 +510,19 @@ def get( :type attachment_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: IssueAttachmentContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueAttachmentContract + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueAttachmentContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueAttachmentContract] request = build_get_request( @@ -491,12 +532,19 @@ def get( issue_id=issue_id, attachment_id=attachment_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -514,7 +562,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}"} # type: ignore @distributed_trace @@ -525,10 +573,10 @@ def create_or_update( api_id: str, issue_id: str, attachment_id: str, - parameters: "_models.IssueAttachmentContract", + parameters: _models.IssueAttachmentContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IssueAttachmentContract": + ) -> _models.IssueAttachmentContract: """Creates a new Attachment for the Issue in an API or updates an existing one. :param resource_group_name: The name of the resource group. @@ -544,22 +592,26 @@ def create_or_update( Issue. :type attachment_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.IssueAttachmentContract + :type parameters: ~azure.mgmt.apimanagement.models.IssueAttachmentContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: IssueAttachmentContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueAttachmentContract + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueAttachmentContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueAttachmentContract] _json = self._serialize.body(parameters, 'IssueAttachmentContract') @@ -570,15 +622,22 @@ def create_or_update( issue_id=issue_id, attachment_id=attachment_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -602,11 +661,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -638,11 +697,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -652,13 +716,20 @@ def delete( issue_id=issue_id, attachment_id=attachment_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -669,5 +740,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_comment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_comment_operations.py index 2501492d6070..e6adae6fea1f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_comment_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_comment_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -39,10 +39,14 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -51,27 +55,25 @@ def build_list_by_service_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -85,10 +87,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -98,21 +104,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -126,10 +130,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -139,21 +147,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -166,17 +172,20 @@ def build_create_or_update_request( comment_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.IssueCommentContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -186,25 +195,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -222,10 +229,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -235,46 +246,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ApiIssueCommentOperations(object): - """ApiIssueCommentOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiIssueCommentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_issue_comment` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -287,7 +294,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.IssueCommentCollection"]: + ) -> Iterable[_models.IssueCommentCollection]: """Lists all comments for the Issue associated with the specified API. :param resource_group_name: The name of the resource group. @@ -302,23 +309,29 @@ def list_by_service( :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either IssueCommentCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.IssueCommentCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IssueCommentCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCommentCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueCommentCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -328,13 +341,16 @@ def prepare_request(next_link=None): api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -344,13 +360,16 @@ def prepare_request(next_link=None): api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -364,7 +383,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -378,7 +401,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments"} # type: ignore @distributed_trace def get_entity_tag( @@ -409,11 +432,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -423,12 +451,19 @@ def get_entity_tag( issue_id=issue_id, comment_id=comment_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -444,7 +479,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}"} # type: ignore @distributed_trace @@ -456,7 +491,7 @@ def get( issue_id: str, comment_id: str, **kwargs: Any - ) -> "_models.IssueCommentContract": + ) -> _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. @@ -472,14 +507,19 @@ def get( :type comment_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: IssueCommentContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueCommentContract + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCommentContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueCommentContract] request = build_get_request( @@ -489,12 +529,19 @@ def get( issue_id=issue_id, comment_id=comment_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -512,7 +559,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}"} # type: ignore @distributed_trace @@ -523,10 +570,10 @@ def create_or_update( api_id: str, issue_id: str, comment_id: str, - parameters: "_models.IssueCommentContract", + parameters: _models.IssueCommentContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IssueCommentContract": + ) -> _models.IssueCommentContract: """Creates a new Comment for the Issue in an API or updates an existing one. :param resource_group_name: The name of the resource group. @@ -541,22 +588,26 @@ def create_or_update( :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. :type comment_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.IssueCommentContract + :type parameters: ~azure.mgmt.apimanagement.models.IssueCommentContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: IssueCommentContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueCommentContract + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCommentContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueCommentContract] _json = self._serialize.body(parameters, 'IssueCommentContract') @@ -567,15 +618,22 @@ def create_or_update( issue_id=issue_id, comment_id=comment_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -599,11 +657,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -634,11 +692,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -648,13 +711,20 @@ def delete( issue_id=issue_id, comment_id=comment_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -665,5 +735,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_operations.py index f6344b38055a..d3c6115ecf2e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -39,10 +39,14 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -50,29 +54,27 @@ def build_list_by_service_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if expand_comments_attachments is not None: - query_parameters['expandCommentsAttachments'] = _SERIALIZER.query("expand_comments_attachments", expand_comments_attachments, 'bool') + _params['expandCommentsAttachments'] = _SERIALIZER.query("expand_comments_attachments", expand_comments_attachments, 'bool') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -85,10 +87,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -97,21 +103,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -126,10 +130,14 @@ def build_get_request( expand_comments_attachments: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -138,23 +146,21 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand_comments_attachments is not None: - query_parameters['expandCommentsAttachments'] = _SERIALIZER.query("expand_comments_attachments", expand_comments_attachments, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['expandCommentsAttachments'] = _SERIALIZER.query("expand_comments_attachments", expand_comments_attachments, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -166,17 +172,20 @@ def build_create_or_update_request( issue_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.IssueContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -185,25 +194,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -218,16 +225,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.IssueUpdateContract] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -236,24 +246,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -270,10 +278,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -282,46 +294,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ApiIssueOperations(object): - """ApiIssueOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiIssueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_issue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -334,7 +342,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.IssueCollection"]: + ) -> Iterable[_models.IssueCollection]: """Lists all issues associated with the specified API. :param resource_group_name: The name of the resource group. @@ -347,24 +355,29 @@ def list_by_service( functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| state | - filter | eq | |
. + filter | eq | |
. Default value is None. :type filter: str - :param expand_comments_attachments: Expand the comment attachments. + :param expand_comments_attachments: Expand the comment attachments. Default value is None. :type expand_comments_attachments: bool - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either IssueCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.IssueCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IssueCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -373,14 +386,17 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, expand_comments_attachments=expand_comments_attachments, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -389,14 +405,17 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, expand_comments_attachments=expand_comments_attachments, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -410,7 +429,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -424,7 +447,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues"} # type: ignore @distributed_trace def get_entity_tag( @@ -451,11 +474,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -464,12 +492,19 @@ def get_entity_tag( api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -485,7 +520,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # type: ignore @distributed_trace @@ -497,7 +532,7 @@ def get( issue_id: str, expand_comments_attachments: Optional[bool] = None, **kwargs: Any - ) -> "_models.IssueContract": + ) -> _models.IssueContract: """Gets the details of the Issue for an API specified by its identifier. :param resource_group_name: The name of the resource group. @@ -509,18 +544,23 @@ def get( :param issue_id: Issue identifier. Must be unique in the current API Management service instance. :type issue_id: str - :param expand_comments_attachments: Expand the comment attachments. + :param expand_comments_attachments: Expand the comment attachments. Default value is None. :type expand_comments_attachments: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: IssueContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueContract + :rtype: ~azure.mgmt.apimanagement.models.IssueContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueContract] request = build_get_request( @@ -529,13 +569,20 @@ def get( api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, expand_comments_attachments=expand_comments_attachments, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -553,7 +600,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # type: ignore @distributed_trace @@ -563,10 +610,10 @@ def create_or_update( service_name: str, api_id: str, issue_id: str, - parameters: "_models.IssueContract", + parameters: _models.IssueContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IssueContract": + ) -> _models.IssueContract: """Creates a new Issue for an API or updates an existing one. :param resource_group_name: The name of the resource group. @@ -579,22 +626,26 @@ def create_or_update( instance. :type issue_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.IssueContract + :type parameters: ~azure.mgmt.apimanagement.models.IssueContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: IssueContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueContract + :rtype: ~azure.mgmt.apimanagement.models.IssueContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueContract] _json = self._serialize.body(parameters, 'IssueContract') @@ -604,15 +655,22 @@ def create_or_update( api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -636,7 +694,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # type: ignore @distributed_trace @@ -647,9 +705,9 @@ def update( api_id: str, issue_id: str, if_match: str, - parameters: "_models.IssueUpdateContract", + parameters: _models.IssueUpdateContract, **kwargs: Any - ) -> "_models.IssueContract": + ) -> _models.IssueContract: """Updates an existing issue for an API. :param resource_group_name: The name of the resource group. @@ -665,19 +723,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.IssueUpdateContract + :type parameters: ~azure.mgmt.apimanagement.models.IssueUpdateContract :keyword callable cls: A custom type or function that will be passed the direct response :return: IssueContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueContract + :rtype: ~azure.mgmt.apimanagement.models.IssueContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueContract] _json = self._serialize.body(parameters, 'IssueUpdateContract') @@ -687,15 +749,22 @@ def update( api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -713,11 +782,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -745,11 +814,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -758,13 +832,20 @@ def delete( api_id=api_id, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -775,5 +856,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_client_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_client_operations.py index cd244845fc93..f6e96902fb83 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_client_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -15,14 +16,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,60 +33,65 @@ def build_perform_connectivity_check_async_request_initial( service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ConnectivityCheckRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class ApiManagementClientOperationsMixin(object): +class ApiManagementClientOperationsMixin(MixinABC): def _perform_connectivity_check_async_initial( self, resource_group_name: str, service_name: str, - connectivity_check_request_params: "_models.ConnectivityCheckRequest", + connectivity_check_request_params: _models.ConnectivityCheckRequest, **kwargs: Any - ) -> Optional["_models.ConnectivityCheckResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ConnectivityCheckResponse"]] + ) -> Optional[_models.ConnectivityCheckResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ConnectivityCheckResponse]] _json = self._serialize.body(connectivity_check_request_params, 'ConnectivityCheckRequest') @@ -94,14 +99,21 @@ def _perform_connectivity_check_async_initial( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._perform_connectivity_check_async_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -117,7 +129,7 @@ def _perform_connectivity_check_async_initial( return deserialized - _perform_connectivity_check_async_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck'} # type: ignore + _perform_connectivity_check_async_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck"} # type: ignore @distributed_trace @@ -125,9 +137,9 @@ def begin_perform_connectivity_check_async( self, resource_group_name: str, service_name: str, - connectivity_check_request_params: "_models.ConnectivityCheckRequest", + connectivity_check_request_params: _models.ConnectivityCheckRequest, **kwargs: Any - ) -> LROPoller["_models.ConnectivityCheckResponse"]: + ) -> LROPoller[_models.ConnectivityCheckResponse]: """Performs a connectivity check between the API Management service and a given destination, and returns metrics for the connection, as well as errors encountered while trying to establish it. @@ -136,7 +148,8 @@ def begin_perform_connectivity_check_async( :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: ~api_management_client.models.ConnectivityCheckRequest + :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 @@ -147,38 +160,51 @@ def begin_perform_connectivity_check_async( Retry-After header is present. :return: An instance of LROPoller that returns either ConnectivityCheckResponse or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.ConnectivityCheckResponse] + :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"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectivityCheckResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._perform_connectivity_check_async_initial( + raw_result = self._perform_connectivity_check_async_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, connectivity_check_request_params=connectivity_check_request_params, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **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() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -187,7 +213,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_perform_connectivity_check_async.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck'} # type: ignore + begin_perform_connectivity_check_async.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_operations_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_operations_operations.py index 5777a7c231cd..286bba4ede89 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_operations_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_operations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request +from .._vendor import MixinABC, _convert_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -29,82 +30,93 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.ApiManagement/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.ApiManagement/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ApiManagementOperationsOperations(object): - """ApiManagementOperationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiManagementOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_management_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> 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 :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.OperationListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -118,7 +130,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,4 +148,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.ApiManagement/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.ApiManagement/operations"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_operations.py index 962b9e7ce1e8..50e2e51dc328 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -34,39 +34,40 @@ def build_restore_request_initial( service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ApiManagementServiceBackupRestoreParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,39 +79,40 @@ def build_backup_request_initial( service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ApiManagementServiceBackupRestoreParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -122,39 +124,40 @@ def build_create_or_update_request_initial( service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ApiManagementServiceResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -166,39 +169,40 @@ def build_update_request_initial( service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ApiManagementServiceUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -211,31 +215,33 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -246,31 +252,33 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -280,30 +288,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -312,29 +322,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -345,31 +357,33 @@ def build_get_sso_token_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -377,37 +391,38 @@ def build_get_sso_token_request( def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ApiManagementServiceCheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -418,29 +433,31 @@ def build_get_domain_ownership_identifier_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -450,80 +467,83 @@ def build_apply_network_configuration_updates_request_initial( service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ApiManagementServiceApplyNetworkConfigurationParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class ApiManagementServiceOperations(object): - """ApiManagementServiceOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiManagementServiceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_management_service` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _restore_initial( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceBackupRestoreParameters", + parameters: _models.ApiManagementServiceBackupRestoreParameters, **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] _json = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') @@ -531,14 +551,21 @@ def _restore_initial( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._restore_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -554,7 +581,7 @@ def _restore_initial( return deserialized - _restore_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore'} # type: ignore + _restore_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore"} # type: ignore @distributed_trace @@ -562,9 +589,9 @@ def begin_restore( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceBackupRestoreParameters", + parameters: _models.ApiManagementServiceBackupRestoreParameters, **kwargs: Any - ) -> LROPoller["_models.ApiManagementServiceResource"]: + ) -> LROPoller[_models.ApiManagementServiceResource]: """Restores a backup of an API Management service created using the ApiManagementService_Backup operation on the current service. This is a long running operation and could take several minutes to complete. @@ -575,7 +602,7 @@ def begin_restore( :type service_name: str :param parameters: Parameters supplied to the Restore API Management service from backup operation. - :type parameters: ~api_management_client.models.ApiManagementServiceBackupRestoreParameters + :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 @@ -587,38 +614,50 @@ def begin_restore( :return: An instance of LROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~api_management_client.models.ApiManagementServiceResource] + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._restore_initial( + raw_result = self._restore_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -627,25 +666,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore'} # type: ignore + begin_restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore"} # type: ignore def _backup_initial( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceBackupRestoreParameters", + parameters: _models.ApiManagementServiceBackupRestoreParameters, **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] _json = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') @@ -653,14 +695,21 @@ def _backup_initial( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._backup_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -676,7 +725,7 @@ def _backup_initial( return deserialized - _backup_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup'} # type: ignore + _backup_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup"} # type: ignore @distributed_trace @@ -684,9 +733,9 @@ def begin_backup( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceBackupRestoreParameters", + parameters: _models.ApiManagementServiceBackupRestoreParameters, **kwargs: Any - ) -> LROPoller["_models.ApiManagementServiceResource"]: + ) -> LROPoller[_models.ApiManagementServiceResource]: """Creates a backup of the API Management service to the given Azure Storage Account. This is long running operation and could take several minutes to complete. @@ -695,7 +744,7 @@ def begin_backup( :param service_name: The name of the API Management service. :type service_name: str :param parameters: Parameters supplied to the ApiManagementService_Backup operation. - :type parameters: ~api_management_client.models.ApiManagementServiceBackupRestoreParameters + :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 @@ -707,38 +756,50 @@ def begin_backup( :return: An instance of LROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~api_management_client.models.ApiManagementServiceResource] + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._backup_initial( + raw_result = self._backup_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -747,25 +808,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_backup.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup'} # type: ignore + begin_backup.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceResource", + parameters: _models.ApiManagementServiceResource, **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] _json = self._serialize.body(parameters, 'ApiManagementServiceResource') @@ -773,14 +837,21 @@ def _create_or_update_initial( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -799,7 +870,7 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore @distributed_trace @@ -807,9 +878,9 @@ def begin_create_or_update( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceResource", + parameters: _models.ApiManagementServiceResource, **kwargs: Any - ) -> LROPoller["_models.ApiManagementServiceResource"]: + ) -> LROPoller[_models.ApiManagementServiceResource]: """Creates or updates an API Management service. This is long running operation and could take several minutes to complete. @@ -818,7 +889,7 @@ def begin_create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param parameters: Parameters supplied to the CreateOrUpdate API Management service operation. - :type parameters: ~api_management_client.models.ApiManagementServiceResource + :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 @@ -830,38 +901,50 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~api_management_client.models.ApiManagementServiceResource] + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -870,25 +953,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore def _update_initial( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceUpdateParameters", + parameters: _models.ApiManagementServiceUpdateParameters, **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] _json = self._serialize.body(parameters, 'ApiManagementServiceUpdateParameters') @@ -896,14 +982,21 @@ def _update_initial( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -919,7 +1012,7 @@ def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore @distributed_trace @@ -927,9 +1020,9 @@ def begin_update( self, resource_group_name: str, service_name: str, - parameters: "_models.ApiManagementServiceUpdateParameters", + parameters: _models.ApiManagementServiceUpdateParameters, **kwargs: Any - ) -> LROPoller["_models.ApiManagementServiceResource"]: + ) -> LROPoller[_models.ApiManagementServiceResource]: """Updates an existing API Management service. :param resource_group_name: The name of the resource group. @@ -937,7 +1030,7 @@ def begin_update( :param service_name: The name of the API Management service. :type service_name: str :param parameters: Parameters supplied to the CreateOrUpdate API Management service operation. - :type parameters: ~api_management_client.models.ApiManagementServiceUpdateParameters + :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 @@ -949,38 +1042,50 @@ def begin_update( :return: An instance of LROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~api_management_client.models.ApiManagementServiceResource] + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -989,10 +1094,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore @distributed_trace def get( @@ -1000,7 +1104,7 @@ def get( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.ApiManagementServiceResource": + ) -> _models.ApiManagementServiceResource: """Gets an API Management service resource description. :param resource_group_name: The name of the resource group. @@ -1009,26 +1113,38 @@ def get( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiManagementServiceResource, or the result of cls(response) - :rtype: ~api_management_client.models.ApiManagementServiceResource + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceResource] request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1043,7 +1159,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore def _delete_initial( @@ -1051,24 +1167,36 @@ def _delete_initial( resource_group_name: str, service_name: str, **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] request = build_delete_request_initial( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -1084,7 +1212,7 @@ def _delete_initial( return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore @distributed_trace @@ -1093,7 +1221,7 @@ def begin_delete( resource_group_name: str, service_name: str, **kwargs: Any - ) -> LROPoller["_models.ApiManagementServiceResource"]: + ) -> LROPoller[_models.ApiManagementServiceResource]: """Deletes an existing API Management service. :param resource_group_name: The name of the resource group. @@ -1111,35 +1239,47 @@ def begin_delete( :return: An instance of LROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~api_management_client.models.ApiManagementServiceResource] + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1148,17 +1288,16 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ApiManagementServiceListResult"]: + ) -> Iterable[_models.ApiManagementServiceListResult]: """List all API Management services within a resource group. :param resource_group_name: The name of the resource group. @@ -1167,34 +1306,45 @@ def list_by_resource_group( :return: An iterator like instance of either ApiManagementServiceListResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~api_management_client.models.ApiManagementServiceListResult] + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1208,7 +1358,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1222,45 +1376,56 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.ApiManagementServiceListResult"]: + ) -> 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[~api_management_client.models.ApiManagementServiceListResult] + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1274,7 +1439,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1288,7 +1457,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service"} # type: ignore @distributed_trace def get_sso_token( @@ -1296,7 +1465,7 @@ def get_sso_token( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.ApiManagementServiceGetSsoTokenResult": + ) -> _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. @@ -1305,26 +1474,38 @@ def get_sso_token( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiManagementServiceGetSsoTokenResult, or the result of cls(response) - :rtype: ~api_management_client.models.ApiManagementServiceGetSsoTokenResult + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetSsoTokenResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceGetSsoTokenResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceGetSsoTokenResult] request = build_get_sso_token_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_sso_token.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1339,45 +1520,56 @@ def get_sso_token( return deserialized - get_sso_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken'} # type: ignore + get_sso_token.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken"} # type: ignore @distributed_trace def check_name_availability( self, - parameters: "_models.ApiManagementServiceCheckNameAvailabilityParameters", + parameters: _models.ApiManagementServiceCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.ApiManagementServiceNameAvailabilityResult": + ) -> _models.ApiManagementServiceNameAvailabilityResult: """Checks availability and correctness of a name for an API Management service. :param parameters: Parameters supplied to the CheckNameAvailability operation. :type parameters: - ~api_management_client.models.ApiManagementServiceCheckNameAvailabilityParameters + ~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: ~api_management_client.models.ApiManagementServiceNameAvailabilityResult + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceNameAvailabilityResult] _json = self._serialize.body(parameters, 'ApiManagementServiceCheckNameAvailabilityParameters') request = build_check_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.check_name_availability.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1392,36 +1584,48 @@ def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability"} # type: ignore @distributed_trace def get_domain_ownership_identifier( self, **kwargs: Any - ) -> "_models.ApiManagementServiceGetDomainOwnershipIdentifierResult": + ) -> _models.ApiManagementServiceGetDomainOwnershipIdentifierResult: """Get the custom domain ownership identifier for an API Management service. :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiManagementServiceGetDomainOwnershipIdentifierResult, or the result of cls(response) - :rtype: ~api_management_client.models.ApiManagementServiceGetDomainOwnershipIdentifierResult + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetDomainOwnershipIdentifierResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceGetDomainOwnershipIdentifierResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceGetDomainOwnershipIdentifierResult] request = build_get_domain_ownership_identifier_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_domain_ownership_identifier.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1436,23 +1640,27 @@ def get_domain_ownership_identifier( return deserialized - get_domain_ownership_identifier.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier'} # type: ignore + get_domain_ownership_identifier.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier"} # type: ignore def _apply_network_configuration_updates_initial( self, resource_group_name: str, service_name: str, - parameters: Optional["_models.ApiManagementServiceApplyNetworkConfigurationParameters"] = None, + parameters: Optional[_models.ApiManagementServiceApplyNetworkConfigurationParameters] = None, **kwargs: Any - ) -> Optional["_models.ApiManagementServiceResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiManagementServiceResource"]] + ) -> Optional[_models.ApiManagementServiceResource]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApiManagementServiceResource]] if parameters is not None: _json = self._serialize.body(parameters, 'ApiManagementServiceApplyNetworkConfigurationParameters') @@ -1463,14 +1671,21 @@ def _apply_network_configuration_updates_initial( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._apply_network_configuration_updates_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1486,7 +1701,7 @@ def _apply_network_configuration_updates_initial( return deserialized - _apply_network_configuration_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates'} # type: ignore + _apply_network_configuration_updates_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates"} # type: ignore @distributed_trace @@ -1494,9 +1709,9 @@ def begin_apply_network_configuration_updates( self, resource_group_name: str, service_name: str, - parameters: Optional["_models.ApiManagementServiceApplyNetworkConfigurationParameters"] = None, + parameters: Optional[_models.ApiManagementServiceApplyNetworkConfigurationParameters] = None, **kwargs: Any - ) -> LROPoller["_models.ApiManagementServiceResource"]: + ) -> LROPoller[_models.ApiManagementServiceResource]: """Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated DNS changes. @@ -1506,9 +1721,9 @@ def begin_apply_network_configuration_updates( :type service_name: str :param parameters: Parameters supplied to the Apply Network Configuration operation. If the parameters are empty, all the regions in which the Api Management service is deployed will be - updated sequentially without incurring downtime in the region. + updated sequentially without incurring downtime in the region. Default value is None. :type parameters: - ~api_management_client.models.ApiManagementServiceApplyNetworkConfigurationParameters + ~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 @@ -1520,38 +1735,50 @@ def begin_apply_network_configuration_updates( :return: An instance of LROPoller that returns either ApiManagementServiceResource or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~api_management_client.models.ApiManagementServiceResource] + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementServiceResource"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementServiceResource] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._apply_network_configuration_updates_initial( + raw_result = self._apply_network_configuration_updates_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1560,7 +1787,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_apply_network_configuration_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates'} # type: ignore + begin_apply_network_configuration_updates.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_skus_operations.py index 02c38580d51e..fc3065f2f849 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_skus_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -32,55 +33,55 @@ def build_list_available_service_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ApiManagementServiceSkusOperations(object): - """ApiManagementServiceSkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiManagementServiceSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_management_service_skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_available_service_skus( @@ -88,7 +89,7 @@ def list_available_service_skus( resource_group_name: str, service_name: str, **kwargs: Any - ) -> Iterable["_models.ResourceSkuResults"]: + ) -> Iterable[_models.ResourceSkuResults]: """Gets available SKUs for API Management service. Gets all available SKU for a given API Management service. @@ -99,14 +100,19 @@ 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.paging.ItemPaged[~api_management_client.models.ResourceSkuResults] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ResourceSkuResults] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkuResults"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceSkuResults] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -114,10 +120,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_available_service_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -125,10 +134,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -142,7 +154,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -156,4 +172,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_available_service_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus'} # type: ignore + list_available_service_skus.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_skus_operations.py index a41bb26691b6..13dea4b7604d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_skus_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -30,90 +31,101 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/skus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/skus") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ApiManagementSkusOperations(object): - """ApiManagementSkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiManagementSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_management_skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.ApiManagementSkusResult"]: + ) -> 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) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ApiManagementSkusResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiManagementSkusResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiManagementSkusResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -127,7 +139,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,4 +157,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/skus"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_operations.py index 8f1aa1bc8117..305e2dbeaed7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -39,10 +39,14 @@ def build_list_by_api_request( tags: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -50,29 +54,27 @@ def build_list_by_api_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) if tags is not None: - query_parameters['tags'] = _SERIALIZER.query("tags", tags, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['tags'] = _SERIALIZER.query("tags", tags, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -85,10 +87,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -97,21 +103,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -124,10 +128,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -136,21 +144,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -162,17 +168,20 @@ def build_create_or_update_request( operation_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.OperationContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -181,25 +190,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -214,16 +221,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.OperationUpdateContract] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -232,24 +242,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -266,10 +274,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -278,46 +290,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ApiOperationOperations(object): - """ApiOperationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiOperationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_operation` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_api( @@ -330,7 +338,7 @@ def list_by_api( skip: Optional[int] = None, tags: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.OperationCollection"]: + ) -> Iterable[_models.OperationCollection]: """Lists a collection of the operations for the specified API. :param resource_group_name: The name of the resource group. @@ -347,24 +355,29 @@ def list_by_api( |
| method | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| urlTemplate | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
. + startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param tags: Include tags in the response. + :param tags: Include tags in the response. Default value is None. :type tags: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.OperationCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.OperationCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -373,14 +386,17 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, tags=tags, template_url=self.list_by_api.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -389,14 +405,17 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, tags=tags, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -410,7 +429,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -424,7 +447,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations'} # type: ignore + list_by_api.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations"} # type: ignore @distributed_trace def get_entity_tag( @@ -452,11 +475,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -465,12 +493,19 @@ def get_entity_tag( api_id=api_id, operation_id=operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -486,7 +521,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # type: ignore @distributed_trace @@ -497,7 +532,7 @@ def get( api_id: str, operation_id: str, **kwargs: Any - ) -> "_models.OperationContract": + ) -> _models.OperationContract: """Gets the details of the API Operation specified by its identifier. :param resource_group_name: The name of the resource group. @@ -512,14 +547,19 @@ def get( :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationContract, or the result of cls(response) - :rtype: ~api_management_client.models.OperationContract + :rtype: ~azure.mgmt.apimanagement.models.OperationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationContract] request = build_get_request( @@ -528,12 +568,19 @@ def get( api_id=api_id, operation_id=operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -551,7 +598,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # type: ignore @distributed_trace @@ -561,10 +608,10 @@ def create_or_update( service_name: str, api_id: str, operation_id: str, - parameters: "_models.OperationContract", + parameters: _models.OperationContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.OperationContract": + ) -> _models.OperationContract: """Creates a new operation in the API or updates an existing one. :param resource_group_name: The name of the resource group. @@ -578,22 +625,26 @@ def create_or_update( Management service instance. :type operation_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.OperationContract + :type parameters: ~azure.mgmt.apimanagement.models.OperationContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationContract, or the result of cls(response) - :rtype: ~api_management_client.models.OperationContract + :rtype: ~azure.mgmt.apimanagement.models.OperationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationContract] _json = self._serialize.body(parameters, 'OperationContract') @@ -603,15 +654,22 @@ def create_or_update( api_id=api_id, operation_id=operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -635,7 +693,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # type: ignore @distributed_trace @@ -646,9 +704,9 @@ def update( api_id: str, operation_id: str, if_match: str, - parameters: "_models.OperationUpdateContract", + parameters: _models.OperationUpdateContract, **kwargs: Any - ) -> "_models.OperationContract": + ) -> _models.OperationContract: """Updates the details of the operation in the API specified by its identifier. :param resource_group_name: The name of the resource group. @@ -665,19 +723,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: API Operation Update parameters. - :type parameters: ~api_management_client.models.OperationUpdateContract + :type parameters: ~azure.mgmt.apimanagement.models.OperationUpdateContract :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationContract, or the result of cls(response) - :rtype: ~api_management_client.models.OperationContract + :rtype: ~azure.mgmt.apimanagement.models.OperationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationContract] _json = self._serialize.body(parameters, 'OperationUpdateContract') @@ -687,15 +749,22 @@ def update( api_id=api_id, operation_id=operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -713,11 +782,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -746,11 +815,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -759,13 +833,20 @@ def delete( api_id=api_id, operation_id=operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -776,5 +857,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_policy_operations.py index 2cc176950b64..100f466c8472 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_policy_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -34,10 +34,14 @@ def build_list_by_operation_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -46,21 +50,19 @@ def build_list_by_operation_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -74,10 +76,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -87,21 +93,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -117,10 +121,14 @@ def build_get_request( format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -130,23 +138,21 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if format is not None: - query_parameters['format'] = _SERIALIZER.query("format", format, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['format'] = _SERIALIZER.query("format", format, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -159,17 +165,20 @@ def build_create_or_update_request( policy_id: Union[str, "_models.PolicyIdName"], subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.PolicyContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -179,25 +188,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -215,10 +222,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -228,46 +239,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ApiOperationPolicyOperations(object): - """ApiOperationPolicyOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiOperationPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_operation_policy` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_operation( @@ -277,7 +284,7 @@ def list_by_operation( api_id: str, operation_id: str, **kwargs: Any - ) -> "_models.PolicyCollection": + ) -> _models.PolicyCollection: """Get the list of policy configuration at the API Operation level. :param resource_group_name: The name of the resource group. @@ -292,14 +299,19 @@ def list_by_operation( :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyCollection + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyCollection] request = build_list_by_operation_request( @@ -308,12 +320,19 @@ def list_by_operation( api_id=api_id, operation_id=operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_operation.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -328,7 +347,7 @@ def list_by_operation( return deserialized - list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies'} # type: ignore + list_by_operation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies"} # type: ignore @distributed_trace @@ -354,17 +373,22 @@ def get_entity_tag( Management service instance. :type operation_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: bool, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -374,12 +398,19 @@ def get_entity_tag( operation_id=operation_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -395,7 +426,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}"} # type: ignore @distributed_trace @@ -408,7 +439,7 @@ def get( policy_id: Union[str, "_models.PolicyIdName"], format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Get the policy configuration at the API Operation level. :param resource_group_name: The name of the resource group. @@ -422,19 +453,24 @@ def get( Management service instance. :type operation_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param format: Policy Export Format. - :type format: str or ~api_management_client.models.PolicyExportFormat + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. Default value is "xml". + :type format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyContract] request = build_get_request( @@ -444,13 +480,20 @@ def get( operation_id=operation_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, format=format, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -468,7 +511,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}"} # type: ignore @distributed_trace @@ -479,10 +522,10 @@ def create_or_update( api_id: str, operation_id: str, policy_id: Union[str, "_models.PolicyIdName"], - parameters: "_models.PolicyContract", + parameters: _models.PolicyContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Creates or updates policy configuration for the API Operation level. :param resource_group_name: The name of the resource group. @@ -496,24 +539,28 @@ def create_or_update( Management service instance. :type operation_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :param parameters: The policy contents to apply. - :type parameters: ~api_management_client.models.PolicyContract + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyContract] _json = self._serialize.body(parameters, 'PolicyContract') @@ -524,15 +571,22 @@ def create_or_update( operation_id=operation_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -556,11 +610,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -583,7 +637,7 @@ def delete( Management service instance. :type operation_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str @@ -592,11 +646,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -606,13 +665,20 @@ def delete( operation_id=operation_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -623,5 +689,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operations.py index e82a954a2e59..2378b25803f7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -41,41 +41,43 @@ def build_list_by_service_request( expand_api_version_set: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) if tags is not None: - query_parameters['tags'] = _SERIALIZER.query("tags", tags, 'str') + _params['tags'] = _SERIALIZER.query("tags", tags, 'str') if expand_api_version_set is not None: - query_parameters['expandApiVersionSet'] = _SERIALIZER.query("expand_api_version_set", expand_api_version_set, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['expandApiVersionSet'] = _SERIALIZER.query("expand_api_version_set", expand_api_version_set, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -87,10 +89,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -98,21 +104,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -124,10 +128,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -135,21 +143,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -160,17 +166,20 @@ def build_create_or_update_request_initial( api_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ApiCreateOrUpdateParameter] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -178,25 +187,23 @@ def build_create_or_update_request_initial( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -210,16 +217,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.ApiUpdateContract] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -227,24 +237,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -261,10 +269,14 @@ def build_delete_request( delete_revisions: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -272,24 +284,22 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if delete_revisions is not None: - query_parameters['deleteRevisions'] = _SERIALIZER.query("delete_revisions", delete_revisions, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['deleteRevisions'] = _SERIALIZER.query("delete_revisions", delete_revisions, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -305,63 +315,63 @@ def build_list_by_tags_request( include_not_tagged_apis: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apisByTags') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apisByTags") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) if include_not_tagged_apis is not None: - query_parameters['includeNotTaggedApis'] = _SERIALIZER.query("include_not_tagged_apis", include_not_tagged_apis, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['includeNotTaggedApis'] = _SERIALIZER.query("include_not_tagged_apis", include_not_tagged_apis, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ApiOperations(object): - """ApiOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -374,7 +384,7 @@ def list_by_service( tags: Optional[str] = None, expand_api_version_set: Optional[bool] = None, **kwargs: Any - ) -> Iterable["_models.ApiCollection"]: + ) -> Iterable[_models.ApiCollection]: """Lists all APIs of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -388,26 +398,32 @@ def list_by_service( |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| serviceUrl | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| isCurrent | filter | eq, ne | |
. + startswith, endswith |
| isCurrent | filter | eq, ne | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param tags: Include tags in the response. + :param tags: Include tags in the response. Default value is None. :type tags: str - :param expand_api_version_set: Include full ApiVersionSet resource in response. + :param expand_api_version_set: Include full ApiVersionSet resource in response. Default value + is None. :type expand_api_version_set: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ApiCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -415,15 +431,18 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, tags=tags, expand_api_version_set=expand_api_version_set, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -431,15 +450,18 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, tags=tags, expand_api_version_set=expand_api_version_set, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -453,7 +475,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -467,7 +493,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis"} # type: ignore @distributed_trace def get_entity_tag( @@ -491,11 +517,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -503,12 +534,19 @@ def get_entity_tag( service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -524,7 +562,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore @distributed_trace @@ -534,7 +572,7 @@ def get( service_name: str, api_id: str, **kwargs: Any - ) -> "_models.ApiContract": + ) -> _models.ApiContract: """Gets the details of the API specified by its identifier. :param resource_group_name: The name of the resource group. @@ -546,14 +584,19 @@ def get( :type api_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiContract + :rtype: ~azure.mgmt.apimanagement.models.ApiContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiContract] request = build_get_request( @@ -561,12 +604,19 @@ def get( service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -584,7 +634,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore def _create_or_update_initial( @@ -592,17 +642,21 @@ def _create_or_update_initial( resource_group_name: str, service_name: str, api_id: str, - parameters: "_models.ApiCreateOrUpdateParameter", + parameters: _models.ApiCreateOrUpdateParameter, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.ApiContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ApiContract"]] + ) -> Optional[_models.ApiContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ApiContract]] _json = self._serialize.body(parameters, 'ApiCreateOrUpdateParameter') @@ -611,15 +665,22 @@ def _create_or_update_initial( service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -643,7 +704,7 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore @distributed_trace @@ -652,10 +713,10 @@ def begin_create_or_update( resource_group_name: str, service_name: str, api_id: str, - parameters: "_models.ApiCreateOrUpdateParameter", + parameters: _models.ApiCreateOrUpdateParameter, if_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.ApiContract"]: + ) -> LROPoller[_models.ApiContract]: """Creates new or updates existing specified API of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -666,9 +727,9 @@ def begin_create_or_update( instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.ApiCreateOrUpdateParameter + :type parameters: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdateParameter :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -680,26 +741,33 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either ApiContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.ApiContract] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiContract] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiContract] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, api_id=api_id, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -715,8 +783,14 @@ def get_long_running_output(pipeline_response): 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() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -725,10 +799,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore @distributed_trace def update( @@ -737,9 +810,9 @@ def update( service_name: str, api_id: str, if_match: str, - parameters: "_models.ApiUpdateContract", + parameters: _models.ApiUpdateContract, **kwargs: Any - ) -> "_models.ApiContract": + ) -> _models.ApiContract: """Updates the specified API of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -753,19 +826,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: API Update Contract parameters. - :type parameters: ~api_management_client.models.ApiUpdateContract + :type parameters: ~azure.mgmt.apimanagement.models.ApiUpdateContract :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiContract + :rtype: ~azure.mgmt.apimanagement.models.ApiContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiContract] _json = self._serialize.body(parameters, 'ApiUpdateContract') @@ -774,15 +851,22 @@ def update( service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -800,11 +884,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -825,18 +909,23 @@ def delete( :param if_match: ETag of 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 - :param delete_revisions: Delete all revisions of the Api. + :param delete_revisions: Delete all revisions of the Api. Default value is None. :type delete_revisions: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -844,14 +933,21 @@ def delete( service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, delete_revisions=delete_revisions, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -862,7 +958,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}"} # type: ignore @distributed_trace @@ -875,7 +971,7 @@ def list_by_tags( skip: Optional[int] = None, include_not_tagged_apis: Optional[bool] = None, **kwargs: Any - ) -> Iterable["_models.TagResourceCollection"]: + ) -> Iterable[_models.TagResourceCollection]: """Lists a collection of apis associated with tags. :param resource_group_name: The name of the resource group. @@ -890,25 +986,31 @@ def list_by_tags( endswith |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| serviceUrl | filter | ge, le, eq, ne, gt, lt | substringof, - contains, startswith, endswith |
| isCurrent | filter | eq | |
. + contains, startswith, endswith |
| isCurrent | filter | eq | |
. Default value is + None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param include_not_tagged_apis: Include not tagged APIs. + :param include_not_tagged_apis: Include not tagged APIs. Default value is None. :type include_not_tagged_apis: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TagResourceCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagResourceCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -916,14 +1018,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, include_not_tagged_apis=include_not_tagged_apis, template_url=self.list_by_tags.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -931,14 +1036,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, include_not_tagged_apis=include_not_tagged_apis, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -952,7 +1060,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -966,4 +1078,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apisByTags'} # type: ignore + list_by_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apisByTags"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_policy_operations.py index e4d0598ec0d5..33323bb6608d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_policy_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,10 +33,14 @@ def build_list_by_api_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -44,21 +48,19 @@ def build_list_by_api_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -71,10 +73,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -83,21 +89,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -112,10 +116,14 @@ def build_get_request( 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" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json, application/vnd.ms-azure-apim.policy+xml, application/vnd.ms-azure-apim.policy.raw+xml") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -124,23 +132,21 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if format is not None: - query_parameters['format'] = _SERIALIZER.query("format", format, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['format'] = _SERIALIZER.query("format", format, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -152,17 +158,20 @@ def build_create_or_update_request( policy_id: Union[str, "_models.PolicyIdName"], subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.PolicyContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -171,25 +180,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -206,10 +213,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -218,46 +229,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ApiPolicyOperations(object): - """ApiPolicyOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_policy` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_api( @@ -266,7 +273,7 @@ def list_by_api( service_name: str, api_id: str, **kwargs: Any - ) -> "_models.PolicyCollection": + ) -> _models.PolicyCollection: """Get the policy configuration at the API level. :param resource_group_name: The name of the resource group. @@ -278,14 +285,19 @@ def list_by_api( :type api_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyCollection + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyCollection] request = build_list_by_api_request( @@ -293,12 +305,19 @@ def list_by_api( service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_api.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -313,7 +332,7 @@ def list_by_api( return deserialized - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies'} # type: ignore + list_by_api.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies"} # type: ignore @distributed_trace @@ -335,17 +354,22 @@ def get_entity_tag( instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: bool, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -354,12 +378,19 @@ def get_entity_tag( api_id=api_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -375,7 +406,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}"} # type: ignore @distributed_trace @@ -387,7 +418,7 @@ def get( policy_id: Union[str, "_models.PolicyIdName"], format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Get the policy configuration at the API level. :param resource_group_name: The name of the resource group. @@ -398,19 +429,24 @@ def get( instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param format: Policy Export Format. - :type format: str or ~api_management_client.models.PolicyExportFormat + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. Default value is "xml". + :type format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyContract] request = build_get_request( @@ -419,13 +455,20 @@ def get( api_id=api_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, format=format, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 200]: @@ -449,7 +492,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}"} # type: ignore @distributed_trace @@ -459,10 +502,10 @@ def create_or_update( service_name: str, api_id: str, policy_id: Union[str, "_models.PolicyIdName"], - parameters: "_models.PolicyContract", + parameters: _models.PolicyContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Creates or updates policy configuration for the API. :param resource_group_name: The name of the resource group. @@ -473,24 +516,28 @@ def create_or_update( instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :param parameters: The policy contents to apply. - :type parameters: ~api_management_client.models.PolicyContract + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyContract] _json = self._serialize.body(parameters, 'PolicyContract') @@ -500,15 +547,22 @@ def create_or_update( api_id=api_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -532,11 +586,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -555,7 +609,7 @@ def delete( instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str @@ -564,11 +618,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -577,13 +636,20 @@ def delete( api_id=api_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -594,5 +660,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_product_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_product_operations.py index e3f4abe61ecd..34bdd6dbb784 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_product_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_product_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -37,10 +38,14 @@ def build_list_by_apis_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/products') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/products") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -48,51 +53,47 @@ def build_list_by_apis_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ApiProductOperations(object): - """ApiProductOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiProductOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_product` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_apis( @@ -104,7 +105,7 @@ def list_by_apis( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ProductCollection"]: + ) -> Iterable[_models.ProductCollection]: """Lists all Products, which the API is part of. :param resource_group_name: The name of the resource group. @@ -115,22 +116,28 @@ def list_by_apis( :type api_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| displayName - | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProductCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ProductCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ProductCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProductCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -139,13 +146,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_apis.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -154,13 +164,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -174,7 +187,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -188,4 +205,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_apis.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/products'} # type: ignore + list_by_apis.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/products"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_release_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_release_operations.py index e75d1fab92dc..9cebd65ec2aa 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_release_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_release_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -38,10 +38,14 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -49,27 +53,25 @@ def build_list_by_service_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -82,10 +84,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -94,21 +100,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -121,10 +125,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -133,21 +141,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -159,17 +165,20 @@ def build_create_or_update_request( release_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ApiReleaseContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -178,25 +187,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -211,16 +218,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.ApiReleaseContract] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -229,24 +239,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -263,10 +271,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -275,46 +287,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ApiReleaseOperations(object): - """ApiReleaseOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiReleaseOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_release` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -326,7 +334,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ApiReleaseCollection"]: + ) -> 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. @@ -339,23 +347,29 @@ def list_by_service( :type api_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| notes | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiReleaseCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ApiReleaseCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiReleaseCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiReleaseCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiReleaseCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -364,13 +378,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -379,13 +396,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -399,7 +419,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -413,7 +437,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases"} # type: ignore @distributed_trace def get_entity_tag( @@ -440,11 +464,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -453,12 +482,19 @@ def get_entity_tag( api_id=api_id, release_id=release_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -474,7 +510,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # type: ignore @distributed_trace @@ -485,7 +521,7 @@ def get( api_id: str, release_id: str, **kwargs: Any - ) -> "_models.ApiReleaseContract": + ) -> _models.ApiReleaseContract: """Returns the details of an API release. :param resource_group_name: The name of the resource group. @@ -499,14 +535,19 @@ def get( :type release_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiReleaseContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiReleaseContract + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiReleaseContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiReleaseContract] request = build_get_request( @@ -515,12 +556,19 @@ def get( api_id=api_id, release_id=release_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -538,7 +586,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # type: ignore @distributed_trace @@ -548,10 +596,10 @@ def create_or_update( service_name: str, api_id: str, release_id: str, - parameters: "_models.ApiReleaseContract", + parameters: _models.ApiReleaseContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ApiReleaseContract": + ) -> _models.ApiReleaseContract: """Creates a new Release for the API. :param resource_group_name: The name of the resource group. @@ -564,22 +612,26 @@ def create_or_update( Management service instance. :type release_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.ApiReleaseContract + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiReleaseContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiReleaseContract + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiReleaseContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiReleaseContract] _json = self._serialize.body(parameters, 'ApiReleaseContract') @@ -589,15 +641,22 @@ def create_or_update( api_id=api_id, release_id=release_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -621,7 +680,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # type: ignore @distributed_trace @@ -632,9 +691,9 @@ def update( api_id: str, release_id: str, if_match: str, - parameters: "_models.ApiReleaseContract", + parameters: _models.ApiReleaseContract, **kwargs: Any - ) -> "_models.ApiReleaseContract": + ) -> _models.ApiReleaseContract: """Updates the details of the release of the API specified by its identifier. :param resource_group_name: The name of the resource group. @@ -650,19 +709,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: API Release Update parameters. - :type parameters: ~api_management_client.models.ApiReleaseContract + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiReleaseContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiReleaseContract + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiReleaseContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiReleaseContract] _json = self._serialize.body(parameters, 'ApiReleaseContract') @@ -672,15 +735,22 @@ def update( api_id=api_id, release_id=release_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -698,11 +768,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -730,11 +800,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -743,13 +818,20 @@ def delete( api_id=api_id, release_id=release_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -760,5 +842,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_revision_operations.py index 0b97f0eb64af..314493240bed 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_revision_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_revision_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -37,10 +38,14 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/revisions') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/revisions") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -48,51 +53,47 @@ def build_list_by_service_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ApiRevisionOperations(object): - """ApiRevisionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiRevisionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_revision` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -104,7 +105,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ApiRevisionCollection"]: + ) -> Iterable[_models.ApiRevisionCollection]: """Lists all revisions of an API. :param resource_group_name: The name of the resource group. @@ -115,23 +116,29 @@ def list_by_service( :type api_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| apiRevision - | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiRevisionCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ApiRevisionCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiRevisionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiRevisionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiRevisionCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -140,13 +147,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -155,13 +165,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -175,7 +188,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -189,4 +206,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/revisions'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/revisions"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_schema_operations.py index 7a9726679060..6a5b1d8de999 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_schema_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_schema_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -40,10 +40,14 @@ def build_list_by_api_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -51,27 +55,25 @@ def build_list_by_api_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -84,10 +86,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -96,21 +102,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -123,10 +127,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -135,21 +143,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -161,17 +167,20 @@ def build_create_or_update_request_initial( schema_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.SchemaContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -180,25 +189,23 @@ def build_create_or_update_request_initial( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -216,10 +223,14 @@ def build_delete_request( force: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -228,48 +239,44 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force is not None: - query_parameters['force'] = _SERIALIZER.query("force", force, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['force'] = _SERIALIZER.query("force", force, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ApiSchemaOperations(object): - """ApiSchemaOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiSchemaOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_schema` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_api( @@ -281,7 +288,7 @@ def list_by_api( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.SchemaCollection"]: + ) -> Iterable[_models.SchemaCollection]: """Get the schema configuration at the API level. :param resource_group_name: The name of the resource group. @@ -293,22 +300,28 @@ def list_by_api( :type api_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| contentType - | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SchemaCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.SchemaCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.SchemaCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SchemaCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SchemaCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -317,13 +330,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_api.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -332,13 +348,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -352,7 +371,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -366,7 +389,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas'} # type: ignore + list_by_api.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas"} # type: ignore @distributed_trace def get_entity_tag( @@ -394,11 +417,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -407,12 +435,19 @@ def get_entity_tag( api_id=api_id, schema_id=schema_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -428,7 +463,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # type: ignore @distributed_trace @@ -439,7 +474,7 @@ def get( api_id: str, schema_id: str, **kwargs: Any - ) -> "_models.SchemaContract": + ) -> _models.SchemaContract: """Get the schema configuration at the API level. :param resource_group_name: The name of the resource group. @@ -454,14 +489,19 @@ def get( :type schema_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SchemaContract, or the result of cls(response) - :rtype: ~api_management_client.models.SchemaContract + :rtype: ~azure.mgmt.apimanagement.models.SchemaContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SchemaContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SchemaContract] request = build_get_request( @@ -470,12 +510,19 @@ def get( api_id=api_id, schema_id=schema_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -493,7 +540,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # type: ignore def _create_or_update_initial( @@ -502,17 +549,21 @@ def _create_or_update_initial( service_name: str, api_id: str, schema_id: str, - parameters: "_models.SchemaContract", + parameters: _models.SchemaContract, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.SchemaContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SchemaContract"]] + ) -> Optional[_models.SchemaContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SchemaContract]] _json = self._serialize.body(parameters, 'SchemaContract') @@ -522,15 +573,22 @@ def _create_or_update_initial( api_id=api_id, schema_id=schema_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -554,7 +612,7 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # type: ignore @distributed_trace @@ -564,10 +622,10 @@ def begin_create_or_update( service_name: str, api_id: str, schema_id: str, - parameters: "_models.SchemaContract", + parameters: _models.SchemaContract, if_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.SchemaContract"]: + ) -> LROPoller[_models.SchemaContract]: """Creates or updates schema configuration for the API. :param resource_group_name: The name of the resource group. @@ -581,9 +639,9 @@ def begin_create_or_update( instance. :type schema_id: str :param parameters: The schema contents to apply. - :type parameters: ~api_management_client.models.SchemaContract + :type parameters: ~azure.mgmt.apimanagement.models.SchemaContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -595,27 +653,34 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either SchemaContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.SchemaContract] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.SchemaContract] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SchemaContract"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SchemaContract] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, api_id=api_id, schema_id=schema_id, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -631,8 +696,14 @@ def get_long_running_output(pipeline_response): 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() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -641,13 +712,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -672,18 +742,24 @@ def delete( :param if_match: ETag of 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 - :param force: If true removes all references to the schema before deleting it. + :param force: If true removes all references to the schema before deleting it. Default value is + None. :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -692,14 +768,21 @@ def delete( api_id=api_id, schema_id=schema_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, force=force, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -710,5 +793,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_tag_description_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_tag_description_operations.py index ff9dc3c66877..c506dc8b44ce 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_tag_description_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_tag_description_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -38,10 +38,14 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -49,27 +53,25 @@ def build_list_by_service_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -82,10 +84,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -94,21 +100,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -121,10 +125,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -133,21 +141,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -159,17 +165,20 @@ def build_create_or_update_request( tag_description_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.TagDescriptionCreateParameters] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -178,25 +187,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -213,10 +220,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -225,46 +236,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ApiTagDescriptionOperations(object): - """ApiTagDescriptionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiTagDescriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_tag_description` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -276,7 +283,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.TagDescriptionCollection"]: + ) -> 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. @@ -290,23 +297,29 @@ def list_by_service( :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagDescriptionCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TagDescriptionCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagDescriptionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDescriptionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagDescriptionCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -315,13 +328,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -330,13 +346,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -350,7 +369,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -364,7 +387,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions"} # type: ignore @distributed_trace def get_entity_tag( @@ -392,11 +415,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -405,12 +433,19 @@ def get_entity_tag( api_id=api_id, tag_description_id=tag_description_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -426,7 +461,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}"} # type: ignore @distributed_trace @@ -437,7 +472,7 @@ def get( api_id: str, tag_description_id: str, **kwargs: Any - ) -> "_models.TagDescriptionContract": + ) -> _models.TagDescriptionContract: """Get Tag description in scope of API. :param resource_group_name: The name of the resource group. @@ -452,14 +487,19 @@ def get( :type tag_description_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagDescriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagDescriptionContract + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDescriptionContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagDescriptionContract] request = build_get_request( @@ -468,12 +508,19 @@ def get( api_id=api_id, tag_description_id=tag_description_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -491,7 +538,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}"} # type: ignore @distributed_trace @@ -501,10 +548,10 @@ def create_or_update( service_name: str, api_id: str, tag_description_id: str, - parameters: "_models.TagDescriptionCreateParameters", + parameters: _models.TagDescriptionCreateParameters, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.TagDescriptionContract": + ) -> _models.TagDescriptionContract: """Create/Update tag description in scope of the Api. :param resource_group_name: The name of the resource group. @@ -518,22 +565,26 @@ def create_or_update( API/Tag association. Based on API and Tag names. :type tag_description_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.TagDescriptionCreateParameters + :type parameters: ~azure.mgmt.apimanagement.models.TagDescriptionCreateParameters :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagDescriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagDescriptionContract + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagDescriptionContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagDescriptionContract] _json = self._serialize.body(parameters, 'TagDescriptionCreateParameters') @@ -543,15 +594,22 @@ def create_or_update( api_id=api_id, tag_description_id=tag_description_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -575,11 +633,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -608,11 +666,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -621,13 +684,20 @@ def delete( api_id=api_id, tag_description_id=tag_description_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -638,5 +708,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_version_set_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_version_set_operations.py index f9c42747ca3f..ec2a5da3ed80 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_version_set_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_version_set_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -79,10 +81,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -90,21 +96,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -116,10 +120,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -127,21 +135,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -152,17 +158,20 @@ def build_create_or_update_request( version_set_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ApiVersionSetContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -170,25 +179,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -202,16 +209,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.ApiVersionSetUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -219,24 +229,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -252,10 +260,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -263,46 +275,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ApiVersionSetOperations(object): - """ApiVersionSetOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ApiVersionSetOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_version_set` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -313,7 +321,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ApiVersionSetCollection"]: + ) -> 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. @@ -321,23 +329,29 @@ def list_by_service( :param service_name: The name of the API Management service. :type service_name: str :param filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
. + functions |
|-------------|-------------|-------------|-------------|
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiVersionSetCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ApiVersionSetCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiVersionSetCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiVersionSetCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiVersionSetCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -345,13 +359,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -359,13 +376,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -379,7 +399,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -393,7 +417,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets"} # type: ignore @distributed_trace def get_entity_tag( @@ -417,11 +441,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -429,12 +458,19 @@ def get_entity_tag( service_name=service_name, version_set_id=version_set_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -450,7 +486,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # type: ignore @distributed_trace @@ -460,7 +496,7 @@ def get( service_name: str, version_set_id: str, **kwargs: Any - ) -> "_models.ApiVersionSetContract": + ) -> _models.ApiVersionSetContract: """Gets the details of the Api Version Set specified by its identifier. :param resource_group_name: The name of the resource group. @@ -472,14 +508,19 @@ def get( :type version_set_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiVersionSetContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiVersionSetContract + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiVersionSetContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiVersionSetContract] request = build_get_request( @@ -487,12 +528,19 @@ def get( service_name=service_name, version_set_id=version_set_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -510,7 +558,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # type: ignore @distributed_trace @@ -519,10 +567,10 @@ def create_or_update( resource_group_name: str, service_name: str, version_set_id: str, - parameters: "_models.ApiVersionSetContract", + parameters: _models.ApiVersionSetContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ApiVersionSetContract": + ) -> _models.ApiVersionSetContract: """Creates or Updates a Api Version Set. :param resource_group_name: The name of the resource group. @@ -533,22 +581,26 @@ def create_or_update( service instance. :type version_set_id: str :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.ApiVersionSetContract + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiVersionSetContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiVersionSetContract + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiVersionSetContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiVersionSetContract] _json = self._serialize.body(parameters, 'ApiVersionSetContract') @@ -557,15 +609,22 @@ def create_or_update( service_name=service_name, version_set_id=version_set_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -589,7 +648,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # type: ignore @distributed_trace @@ -599,9 +658,9 @@ def update( service_name: str, version_set_id: str, if_match: str, - parameters: "_models.ApiVersionSetUpdateParameters", + parameters: _models.ApiVersionSetUpdateParameters, **kwargs: Any - ) -> "_models.ApiVersionSetContract": + ) -> _models.ApiVersionSetContract: """Updates the details of the Api VersionSet specified by its identifier. :param resource_group_name: The name of the resource group. @@ -615,19 +674,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.ApiVersionSetUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiVersionSetContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiVersionSetContract + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiVersionSetContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiVersionSetContract] _json = self._serialize.body(parameters, 'ApiVersionSetUpdateParameters') @@ -636,15 +699,22 @@ def update( service_name=service_name, version_set_id=version_set_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -662,11 +732,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -691,11 +761,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -703,13 +778,20 @@ def delete( service_name=service_name, version_set_id=version_set_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -720,5 +802,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_access_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_access_policy_operations.py new file mode 100644 index 000000000000..b45ba0c7c9dc --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_access_policy_operations.py @@ -0,0 +1,608 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +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.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_authorization_request( + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accesspolicies") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "authorizationId": _SERIALIZER.url("authorization_id", authorization_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accesspolicies/{authorizationAccessPolicyId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "authorizationId": _SERIALIZER.url("authorization_id", authorization_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "authorizationAccessPolicyId": _SERIALIZER.url("authorization_access_policy_id", authorization_access_policy_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + subscription_id: str, + *, + json: Optional[_models.AuthorizationAccessPolicyContract] = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accesspolicies/{authorizationAccessPolicyId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "authorizationId": _SERIALIZER.url("authorization_id", authorization_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "authorizationAccessPolicyId": _SERIALIZER.url("authorization_access_policy_id", authorization_access_policy_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if if_match is not None: + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accesspolicies/{authorizationAccessPolicyId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "authorizationId": _SERIALIZER.url("authorization_id", authorization_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "authorizationAccessPolicyId": _SERIALIZER.url("authorization_access_policy_id", authorization_access_policy_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class AuthorizationAccessPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`authorization_access_policy` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_authorization( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable[_models.AuthorizationAccessPolicyCollection]: + """Lists a collection of authorization access policy defined within a authorization. + + :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 authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. + :type authorization_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AuthorizationAccessPolicyCollection or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationAccessPolicyCollection] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_authorization_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + top=top, + skip=skip, + template_url=self.list_by_authorization.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_authorization_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + top=top, + skip=skip, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AuthorizationAccessPolicyCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=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_authorization.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accesspolicies"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + **kwargs: Any + ) -> _models.AuthorizationAccessPolicyContract: + """Gets the details of the authorization access policy specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. + :type authorization_id: str + :param authorization_access_policy_id: Identifier of the authorization access policy. + :type authorization_access_policy_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationAccessPolicyContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationAccessPolicyContract] + + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + authorization_access_policy_id=authorization_access_policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('AuthorizationAccessPolicyContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accesspolicies/{authorizationAccessPolicyId}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + parameters: _models.AuthorizationAccessPolicyContract, + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.AuthorizationAccessPolicyContract: + """Creates or updates Authorization Access Policy. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. + :type authorization_id: str + :param authorization_access_policy_id: Identifier of the authorization access policy. + :type authorization_access_policy_id: str + :param parameters: Create parameters. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationAccessPolicyContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationAccessPolicyContract] + + _json = self._serialize.body(parameters, 'AuthorizationAccessPolicyContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + authorization_access_policy_id=authorization_access_policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('AuthorizationAccessPolicyContract', pipeline_response) + + 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}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accesspolicies/{authorizationAccessPolicyId}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes specific access policy from the Authorization. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. + :type authorization_id: str + :param authorization_access_policy_id: Identifier of the authorization access policy. + :type authorization_access_policy_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + authorization_access_policy_id=authorization_access_policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = 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}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accesspolicies/{authorizationAccessPolicyId}"} # type: ignore + diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_login_links_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_login_links_operations.py new file mode 100644 index 000000000000..a380bf39ff80 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_login_links_operations.py @@ -0,0 +1,177 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer + +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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_post_request( + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + subscription_id: str, + *, + json: Optional[_models.AuthorizationLoginRequestContract] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/getLoginLinks") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "authorizationId": _SERIALIZER.url("authorization_id", authorization_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class AuthorizationLoginLinksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`authorization_login_links` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def post( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: _models.AuthorizationLoginRequestContract, + **kwargs: Any + ) -> _models.AuthorizationLoginResponseContract: + """Gets authorization login links. + + :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 authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. + :type authorization_id: str + :param parameters: Create parameters. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationLoginRequestContract + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationLoginResponseContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationLoginResponseContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationLoginResponseContract] + + _json = self._serialize.body(parameters, 'AuthorizationLoginRequestContract') + + request = build_post_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.post.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('AuthorizationLoginResponseContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + post.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/getLoginLinks"} # type: ignore + diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_operations.py new file mode 100644 index 000000000000..57f6003629be --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_operations.py @@ -0,0 +1,582 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +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.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_authorization_provider_request( + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "authorizationId": _SERIALIZER.url("authorization_id", authorization_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + subscription_id: str, + *, + json: Optional[_models.AuthorizationContract] = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "authorizationId": _SERIALIZER.url("authorization_id", authorization_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if if_match is not None: + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "authorizationId": _SERIALIZER.url("authorization_id", authorization_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class AuthorizationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`authorization` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_authorization_provider( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable[_models.AuthorizationCollection]: + """Lists a collection of authorization providers defined within a authorization provider. + + :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 authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AuthorizationCollection or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AuthorizationCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationCollection] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_authorization_provider_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + top=top, + skip=skip, + template_url=self.list_by_authorization_provider.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_authorization_provider_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + top=top, + skip=skip, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AuthorizationCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=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_authorization_provider.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + **kwargs: Any + ) -> _models.AuthorizationContract: + """Gets the details of the authorization specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. + :type authorization_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationContract] + + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('AuthorizationContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: _models.AuthorizationContract, + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.AuthorizationContract: + """Creates or updates authorization. + + :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 authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. + :type authorization_id: str + :param parameters: Create parameters. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationContract] + + _json = self._serialize.body(parameters, 'AuthorizationContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('AuthorizationContract', pipeline_response) + + 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}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes specific Authorization from the Authorization provider. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. + :type authorization_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = 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}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}"} # type: ignore + diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_provider_operations.py new file mode 100644 index 000000000000..55ca70966558 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_provider_operations.py @@ -0,0 +1,558 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +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.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, 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 + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + subscription_id: str, + *, + json: Optional[_models.AuthorizationProviderContract] = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if if_match is not None: + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class AuthorizationProviderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`authorization_provider` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> Iterable[_models.AuthorizationProviderCollection]: + """Lists a collection of authorization providers defined within a 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 |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
. Default value is None. + :type filter: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AuthorizationProviderCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AuthorizationProviderCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationProviderCollection] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + top=top, + skip=skip, + template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + top=top, + skip=skip, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AuthorizationProviderCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=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}/authorizationProviders"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + **kwargs: Any + ) -> _models.AuthorizationProviderContract: + """Gets the details of the authorization provider specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationProviderContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationProviderContract] + + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('AuthorizationProviderContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + parameters: _models.AuthorizationProviderContract, + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.AuthorizationProviderContract: + """Creates or updates authorization provider. + + :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 authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param parameters: Create parameters. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationProviderContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationProviderContract] + + _json = self._serialize.body(parameters, 'AuthorizationProviderContract') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('AuthorizationProviderContract', pipeline_response) + + 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}/authorizationProviders/{authorizationProviderId}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes specific authorization provider from the API Management service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. + :type authorization_provider_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = 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}/authorizationProviders/{authorizationProviderId}"} # 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 7a6bc20bd498..0c8a49720742 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_server_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_server_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -79,10 +81,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -90,21 +96,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -116,10 +120,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -127,21 +135,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -152,17 +158,20 @@ def build_create_or_update_request( authsid: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AuthorizationServerContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -170,25 +179,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -202,16 +209,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.AuthorizationServerUpdateContract] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -219,24 +229,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -252,10 +260,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -263,22 +275,20 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -290,10 +300,14 @@ def build_list_secrets_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}/listSecrets') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}/listSecrets") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -301,45 +315,41 @@ def build_list_secrets_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class AuthorizationServerOperations(object): - """AuthorizationServerOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AuthorizationServerOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`authorization_server` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -350,7 +360,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.AuthorizationServerCollection"]: + ) -> Iterable[_models.AuthorizationServerCollection]: """Lists a collection of authorization servers defined within a service instance. :param resource_group_name: The name of the resource group. @@ -361,24 +371,29 @@ def list_by_service( functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
. + |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AuthorizationServerCollection or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~api_management_client.models.AuthorizationServerCollection] + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AuthorizationServerCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationServerCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -386,13 +401,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -400,13 +418,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -420,7 +441,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -434,7 +459,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers"} # type: ignore @distributed_trace def get_entity_tag( @@ -457,11 +482,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -469,12 +499,19 @@ def get_entity_tag( service_name=service_name, authsid=authsid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -490,7 +527,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # type: ignore @distributed_trace @@ -500,7 +537,7 @@ def get( service_name: str, authsid: str, **kwargs: Any - ) -> "_models.AuthorizationServerContract": + ) -> _models.AuthorizationServerContract: """Gets the details of the authorization server specified by its identifier. :param resource_group_name: The name of the resource group. @@ -511,14 +548,19 @@ def get( :type authsid: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AuthorizationServerContract, or the result of cls(response) - :rtype: ~api_management_client.models.AuthorizationServerContract + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationServerContract] request = build_get_request( @@ -526,12 +568,19 @@ def get( service_name=service_name, authsid=authsid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -549,7 +598,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # type: ignore @distributed_trace @@ -558,10 +607,10 @@ def create_or_update( resource_group_name: str, service_name: str, authsid: str, - parameters: "_models.AuthorizationServerContract", + parameters: _models.AuthorizationServerContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.AuthorizationServerContract": + ) -> _models.AuthorizationServerContract: """Creates new authorization server or updates an existing authorization server. :param resource_group_name: The name of the resource group. @@ -571,22 +620,26 @@ def create_or_update( :param authsid: Identifier of the authorization server. :type authsid: str :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.AuthorizationServerContract + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AuthorizationServerContract, or the result of cls(response) - :rtype: ~api_management_client.models.AuthorizationServerContract + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationServerContract] _json = self._serialize.body(parameters, 'AuthorizationServerContract') @@ -595,15 +648,22 @@ def create_or_update( service_name=service_name, authsid=authsid, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -627,7 +687,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # type: ignore @distributed_trace @@ -637,9 +697,9 @@ def update( service_name: str, authsid: str, if_match: str, - parameters: "_models.AuthorizationServerUpdateContract", + parameters: _models.AuthorizationServerUpdateContract, **kwargs: Any - ) -> "_models.AuthorizationServerContract": + ) -> _models.AuthorizationServerContract: """Updates the details of the authorization server specified by its identifier. :param resource_group_name: The name of the resource group. @@ -652,19 +712,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: OAuth2 Server settings Update parameters. - :type parameters: ~api_management_client.models.AuthorizationServerUpdateContract + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerUpdateContract :keyword callable cls: A custom type or function that will be passed the direct response :return: AuthorizationServerContract, or the result of cls(response) - :rtype: ~api_management_client.models.AuthorizationServerContract + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationServerContract] _json = self._serialize.body(parameters, 'AuthorizationServerUpdateContract') @@ -673,15 +737,22 @@ def update( service_name=service_name, authsid=authsid, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -699,11 +770,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -727,11 +798,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -739,13 +815,20 @@ def delete( service_name=service_name, authsid=authsid, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -756,7 +839,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}"} # type: ignore @distributed_trace @@ -766,7 +849,7 @@ def list_secrets( service_name: str, authsid: str, **kwargs: Any - ) -> "_models.AuthorizationServerSecretsContract": + ) -> _models.AuthorizationServerSecretsContract: """Gets the client secret details of the authorization server. :param resource_group_name: The name of the resource group. @@ -777,14 +860,19 @@ def list_secrets( :type authsid: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AuthorizationServerSecretsContract, or the result of cls(response) - :rtype: ~api_management_client.models.AuthorizationServerSecretsContract + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerSecretsContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationServerSecretsContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AuthorizationServerSecretsContract] request = build_list_secrets_request( @@ -792,12 +880,19 @@ def list_secrets( service_name=service_name, authsid=authsid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_secrets.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -815,5 +910,5 @@ def list_secrets( return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}/listSecrets'} # type: ignore + list_secrets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_backend_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_backend_operations.py index 3c0027e30913..16498aba19b9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_backend_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_backend_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -79,10 +81,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -90,21 +96,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -116,10 +120,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -127,21 +135,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -152,17 +158,20 @@ def build_create_or_update_request( backend_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BackendContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -170,25 +179,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -202,16 +209,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.BackendUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -219,24 +229,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -252,10 +260,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -263,22 +275,20 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -289,16 +299,19 @@ def build_reconnect_request( backend_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BackendReconnectContract] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}/reconnect') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}/reconnect") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -306,49 +319,45 @@ def build_reconnect_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class BackendOperations(object): - """BackendOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BackendOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`backend` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -359,7 +368,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.BackendCollection"]: + ) -> Iterable[_models.BackendCollection]: """Lists a collection of backends in the specified service instance. :param resource_group_name: The name of the resource group. @@ -370,22 +379,28 @@ def list_by_service( functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| title | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| url | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BackendCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.BackendCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.BackendCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackendCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BackendCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -393,13 +408,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -407,13 +425,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -427,7 +448,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -441,7 +466,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends"} # type: ignore @distributed_trace def get_entity_tag( @@ -465,11 +490,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -477,12 +507,19 @@ def get_entity_tag( service_name=service_name, backend_id=backend_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -498,7 +535,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # type: ignore @distributed_trace @@ -508,7 +545,7 @@ def get( service_name: str, backend_id: str, **kwargs: Any - ) -> "_models.BackendContract": + ) -> _models.BackendContract: """Gets the details of the backend specified by its identifier. :param resource_group_name: The name of the resource group. @@ -520,14 +557,19 @@ def get( :type backend_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BackendContract, or the result of cls(response) - :rtype: ~api_management_client.models.BackendContract + :rtype: ~azure.mgmt.apimanagement.models.BackendContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackendContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BackendContract] request = build_get_request( @@ -535,12 +577,19 @@ def get( service_name=service_name, backend_id=backend_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -558,7 +607,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # type: ignore @distributed_trace @@ -567,10 +616,10 @@ def create_or_update( resource_group_name: str, service_name: str, backend_id: str, - parameters: "_models.BackendContract", + parameters: _models.BackendContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.BackendContract": + ) -> _models.BackendContract: """Creates or Updates a backend. :param resource_group_name: The name of the resource group. @@ -581,22 +630,26 @@ def create_or_update( Management service instance. :type backend_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.BackendContract + :type parameters: ~azure.mgmt.apimanagement.models.BackendContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BackendContract, or the result of cls(response) - :rtype: ~api_management_client.models.BackendContract + :rtype: ~azure.mgmt.apimanagement.models.BackendContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackendContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.BackendContract] _json = self._serialize.body(parameters, 'BackendContract') @@ -605,15 +658,22 @@ def create_or_update( service_name=service_name, backend_id=backend_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -637,7 +697,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # type: ignore @distributed_trace @@ -647,9 +707,9 @@ def update( service_name: str, backend_id: str, if_match: str, - parameters: "_models.BackendUpdateParameters", + parameters: _models.BackendUpdateParameters, **kwargs: Any - ) -> "_models.BackendContract": + ) -> _models.BackendContract: """Updates an existing backend. :param resource_group_name: The name of the resource group. @@ -663,19 +723,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.BackendUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.BackendUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: BackendContract, or the result of cls(response) - :rtype: ~api_management_client.models.BackendContract + :rtype: ~azure.mgmt.apimanagement.models.BackendContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BackendContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.BackendContract] _json = self._serialize.body(parameters, 'BackendUpdateParameters') @@ -684,15 +748,22 @@ def update( service_name=service_name, backend_id=backend_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -710,11 +781,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -739,11 +810,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -751,13 +827,20 @@ def delete( service_name=service_name, backend_id=backend_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -768,16 +851,16 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}"} # type: ignore @distributed_trace - def reconnect( + def reconnect( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, backend_id: str, - parameters: Optional["_models.BackendReconnectContract"] = None, + parameters: Optional[_models.BackendReconnectContract] = None, **kwargs: Any ) -> None: """Notifies the APIM proxy to create a new connection to the backend after the specified timeout. @@ -790,20 +873,24 @@ def reconnect( :param backend_id: Identifier of the Backend entity. Must be unique in the current API Management service instance. :type backend_id: str - :param parameters: Reconnect request parameters. - :type parameters: ~api_management_client.models.BackendReconnectContract + :param parameters: Reconnect request parameters. Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.BackendReconnectContract :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'BackendReconnectContract') @@ -815,14 +902,21 @@ def reconnect( service_name=service_name, backend_id=backend_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.reconnect.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [202]: @@ -833,5 +927,5 @@ def reconnect( if cls: return cls(pipeline_response, None, {}) - reconnect.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}/reconnect'} # type: ignore + reconnect.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}/reconnect"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_cache_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_cache_operations.py index 8d028e467c4b..1fc6d33e376b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_cache_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_cache_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -36,35 +36,37 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -76,10 +78,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -87,21 +93,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -113,10 +117,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -124,21 +132,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -149,17 +155,20 @@ def build_create_or_update_request( cache_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CacheContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -167,25 +176,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -199,16 +206,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.CacheUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -216,24 +226,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -249,10 +257,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -260,46 +272,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class CacheOperations(object): - """CacheOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CacheOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`cache` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -309,27 +317,32 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.CacheCollection"]: + ) -> 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. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CacheCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.CacheCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.CacheCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CacheCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CacheCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -337,12 +350,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -350,12 +366,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -369,7 +388,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -383,7 +406,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches"} # type: ignore @distributed_trace def get_entity_tag( @@ -407,11 +430,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -419,12 +447,19 @@ def get_entity_tag( service_name=service_name, cache_id=cache_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -440,7 +475,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # type: ignore @distributed_trace @@ -450,7 +485,7 @@ def get( service_name: str, cache_id: str, **kwargs: Any - ) -> "_models.CacheContract": + ) -> _models.CacheContract: """Gets the details of the Cache specified by its identifier. :param resource_group_name: The name of the resource group. @@ -462,14 +497,19 @@ def get( :type cache_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CacheContract, or the result of cls(response) - :rtype: ~api_management_client.models.CacheContract + :rtype: ~azure.mgmt.apimanagement.models.CacheContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CacheContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CacheContract] request = build_get_request( @@ -477,12 +517,19 @@ def get( service_name=service_name, cache_id=cache_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -500,7 +547,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # type: ignore @distributed_trace @@ -509,10 +556,10 @@ def create_or_update( resource_group_name: str, service_name: str, cache_id: str, - parameters: "_models.CacheContract", + parameters: _models.CacheContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CacheContract": + ) -> _models.CacheContract: """Creates or updates an External Cache to be used in Api Management instance. :param resource_group_name: The name of the resource group. @@ -523,22 +570,26 @@ def create_or_update( or valid Azure region identifier). :type cache_id: str :param parameters: Create or Update parameters. - :type parameters: ~api_management_client.models.CacheContract + :type parameters: ~azure.mgmt.apimanagement.models.CacheContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CacheContract, or the result of cls(response) - :rtype: ~api_management_client.models.CacheContract + :rtype: ~azure.mgmt.apimanagement.models.CacheContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CacheContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CacheContract] _json = self._serialize.body(parameters, 'CacheContract') @@ -547,15 +598,22 @@ def create_or_update( service_name=service_name, cache_id=cache_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -579,7 +637,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # type: ignore @distributed_trace @@ -589,9 +647,9 @@ def update( service_name: str, cache_id: str, if_match: str, - parameters: "_models.CacheUpdateParameters", + parameters: _models.CacheUpdateParameters, **kwargs: Any - ) -> "_models.CacheContract": + ) -> _models.CacheContract: """Updates the details of the cache specified by its identifier. :param resource_group_name: The name of the resource group. @@ -605,19 +663,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.CacheUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.CacheUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: CacheContract, or the result of cls(response) - :rtype: ~api_management_client.models.CacheContract + :rtype: ~azure.mgmt.apimanagement.models.CacheContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CacheContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CacheContract] _json = self._serialize.body(parameters, 'CacheUpdateParameters') @@ -626,15 +688,22 @@ def update( service_name=service_name, cache_id=cache_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -652,11 +721,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -681,11 +750,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -693,13 +767,20 @@ def delete( service_name=service_name, cache_id=cache_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -710,5 +791,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_certificate_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_certificate_operations.py index 988459941cfc..57b138952ec2 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_certificate_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_certificate_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -38,39 +38,41 @@ def build_list_by_service_request( is_key_vault_refresh_failed: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) if is_key_vault_refresh_failed is not None: - query_parameters['isKeyVaultRefreshFailed'] = _SERIALIZER.query("is_key_vault_refresh_failed", is_key_vault_refresh_failed, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['isKeyVaultRefreshFailed'] = _SERIALIZER.query("is_key_vault_refresh_failed", is_key_vault_refresh_failed, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -82,10 +84,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -93,21 +99,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -119,10 +123,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -130,21 +138,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -155,17 +161,20 @@ def build_create_or_update_request( certificate_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CertificateCreateOrUpdateParameters] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -173,25 +182,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -207,10 +214,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -218,22 +229,20 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -245,10 +254,14 @@ def build_refresh_secret_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}/refreshSecret') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}/refreshSecret") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -256,45 +269,41 @@ def build_refresh_secret_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class CertificateOperations(object): - """CertificateOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CertificateOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`certificate` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -306,7 +315,7 @@ def list_by_service( skip: Optional[int] = None, is_key_vault_refresh_failed: Optional[bool] = None, **kwargs: Any - ) -> Iterable["_models.CertificateCollection"]: + ) -> Iterable[_models.CertificateCollection]: """Lists a collection of all certificates in the specified service instance. :param resource_group_name: The name of the resource group. @@ -318,26 +327,31 @@ def list_by_service( filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| subject | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| thumbprint | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
| expirationDate | filter | ge, le, eq, ne, gt, lt | |
. + |
| expirationDate | filter | ge, le, eq, ne, gt, lt | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :param is_key_vault_refresh_failed: When set to true, the response contains only certificates - entities which failed refresh. + entities which failed refresh. Default value is None. :type is_key_vault_refresh_failed: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CertificateCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.CertificateCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.CertificateCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CertificateCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -345,14 +359,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, is_key_vault_refresh_failed=is_key_vault_refresh_failed, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -360,14 +377,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, is_key_vault_refresh_failed=is_key_vault_refresh_failed, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -381,7 +401,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -395,7 +419,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates"} # type: ignore @distributed_trace def get_entity_tag( @@ -419,11 +443,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -431,12 +460,19 @@ def get_entity_tag( service_name=service_name, certificate_id=certificate_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -452,7 +488,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}"} # type: ignore @distributed_trace @@ -462,7 +498,7 @@ def get( service_name: str, certificate_id: str, **kwargs: Any - ) -> "_models.CertificateContract": + ) -> _models.CertificateContract: """Gets the details of the certificate specified by its identifier. :param resource_group_name: The name of the resource group. @@ -474,14 +510,19 @@ def get( :type certificate_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateContract, or the result of cls(response) - :rtype: ~api_management_client.models.CertificateContract + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CertificateContract] request = build_get_request( @@ -489,12 +530,19 @@ def get( service_name=service_name, certificate_id=certificate_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -512,7 +560,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}"} # type: ignore @distributed_trace @@ -521,10 +569,10 @@ def create_or_update( resource_group_name: str, service_name: str, certificate_id: str, - parameters: "_models.CertificateCreateOrUpdateParameters", + parameters: _models.CertificateCreateOrUpdateParameters, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateContract": + ) -> _models.CertificateContract: """Creates or updates the certificate being used for authentication with the backend. :param resource_group_name: The name of the resource group. @@ -535,22 +583,26 @@ def create_or_update( Management service instance. :type certificate_id: str :param parameters: Create or Update parameters. - :type parameters: ~api_management_client.models.CertificateCreateOrUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.CertificateCreateOrUpdateParameters :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateContract, or the result of cls(response) - :rtype: ~api_management_client.models.CertificateContract + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CertificateContract] _json = self._serialize.body(parameters, 'CertificateCreateOrUpdateParameters') @@ -559,15 +611,22 @@ def create_or_update( service_name=service_name, certificate_id=certificate_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -591,11 +650,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -620,11 +679,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -632,13 +696,20 @@ def delete( service_name=service_name, certificate_id=certificate_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -649,7 +720,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}"} # type: ignore @distributed_trace @@ -659,7 +730,7 @@ def refresh_secret( service_name: str, certificate_id: str, **kwargs: Any - ) -> "_models.CertificateContract": + ) -> _models.CertificateContract: """From KeyVault, Refresh the certificate being used for authentication with the backend. :param resource_group_name: The name of the resource group. @@ -671,14 +742,19 @@ def refresh_secret( :type certificate_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateContract, or the result of cls(response) - :rtype: ~api_management_client.models.CertificateContract + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CertificateContract] request = build_refresh_secret_request( @@ -686,12 +762,19 @@ def refresh_secret( service_name=service_name, certificate_id=certificate_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.refresh_secret.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -709,5 +792,5 @@ def refresh_secret( return deserialized - refresh_secret.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}/refreshSecret'} # type: ignore + refresh_secret.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}/refreshSecret"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_item_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_item_operations.py index e637bf6033b1..6c50ed1170f5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_item_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_item_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -33,10 +34,14 @@ def build_list_by_service_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -44,21 +49,19 @@ def build_list_by_service_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -71,10 +74,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -83,21 +90,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -110,10 +115,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -122,21 +131,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -151,10 +158,14 @@ def build_create_or_update_request( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -163,23 +174,21 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -194,10 +203,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -206,46 +219,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ContentItemOperations(object): - """ContentItemOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ContentItemOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`content_item` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -254,7 +263,7 @@ def list_by_service( service_name: str, content_type_id: str, **kwargs: Any - ) -> Iterable["_models.ContentItemCollection"]: + ) -> 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. @@ -266,14 +275,19 @@ def list_by_service( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ContentItemCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ContentItemCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ContentItemCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentItemCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentItemCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -282,10 +296,13 @@ def prepare_request(next_link=None): service_name=service_name, content_type_id=content_type_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -294,10 +311,13 @@ def prepare_request(next_link=None): service_name=service_name, content_type_id=content_type_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -311,7 +331,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -325,7 +349,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems"} # type: ignore @distributed_trace def get_entity_tag( @@ -352,11 +376,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -365,12 +394,19 @@ def get_entity_tag( content_type_id=content_type_id, content_item_id=content_item_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -386,7 +422,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}"} # type: ignore @distributed_trace @@ -397,7 +433,7 @@ def get( content_type_id: str, content_item_id: str, **kwargs: Any - ) -> "_models.ContentItemContract": + ) -> _models.ContentItemContract: """Returns the developer portal's content item specified by its identifier. :param resource_group_name: The name of the resource group. @@ -410,14 +446,19 @@ def get( :type content_item_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ContentItemContract, or the result of cls(response) - :rtype: ~api_management_client.models.ContentItemContract + :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentItemContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentItemContract] request = build_get_request( @@ -426,12 +467,19 @@ def get( content_type_id=content_type_id, content_item_id=content_item_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -449,7 +497,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}"} # type: ignore @distributed_trace @@ -461,7 +509,7 @@ def create_or_update( content_item_id: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ContentItemContract": + ) -> _models.ContentItemContract: """Creates a new developer portal's content item specified by the provided content type. :param resource_group_name: The name of the resource group. @@ -473,18 +521,23 @@ def create_or_update( :param content_item_id: Content item identifier. :type content_item_id: str :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ContentItemContract, or the result of cls(response) - :rtype: ~api_management_client.models.ContentItemContract + :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentItemContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentItemContract] request = build_create_or_update_request( @@ -493,13 +546,20 @@ def create_or_update( content_type_id=content_type_id, content_item_id=content_item_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -523,11 +583,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -554,11 +614,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -567,13 +632,20 @@ def delete( content_type_id=content_type_id, content_item_id=content_item_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -584,5 +656,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_operations.py index ed923ccd8891..ecb7984b600d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -32,31 +33,33 @@ def build_list_by_service_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -68,10 +71,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -79,21 +86,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -104,13 +109,20 @@ def build_create_or_update_request( content_type_id: str, subscription_id: str, *, + json: Optional[_models.ContentTypeContract] = None, + content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -118,23 +130,25 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, **kwargs ) @@ -148,10 +162,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -159,46 +177,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ContentTypeOperations(object): - """ContentTypeOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ContentTypeOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`content_type` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -206,7 +220,7 @@ def list_by_service( resource_group_name: str, service_name: str, **kwargs: Any - ) -> Iterable["_models.ContentTypeCollection"]: + ) -> Iterable[_models.ContentTypeCollection]: """Lists the developer portal's content types. Content types describe content items' properties, validation rules, and constraints. @@ -217,14 +231,19 @@ def list_by_service( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ContentTypeCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ContentTypeCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ContentTypeCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentTypeCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentTypeCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -232,10 +251,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -243,10 +265,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -260,7 +285,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -274,7 +303,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes"} # type: ignore @distributed_trace def get( @@ -283,7 +312,7 @@ def get( service_name: str, content_type_id: str, **kwargs: Any - ) -> "_models.ContentTypeContract": + ) -> _models.ContentTypeContract: """Gets the details of the developer portal's content type. Content types describe content items' properties, validation rules, and constraints. @@ -295,14 +324,19 @@ def get( :type content_type_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ContentTypeContract, or the result of cls(response) - :rtype: ~api_management_client.models.ContentTypeContract + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentTypeContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentTypeContract] request = build_get_request( @@ -310,12 +344,19 @@ def get( service_name=service_name, content_type_id=content_type_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -333,7 +374,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}"} # type: ignore @distributed_trace @@ -343,8 +384,9 @@ def create_or_update( service_name: str, content_type_id: str, if_match: Optional[str] = None, + parameters: Optional[_models.ContentTypeContract] = None, **kwargs: Any - ) -> "_models.ContentTypeContract": + ) -> _models.ContentTypeContract: """Creates or updates the developer portal's content type. Content types describe content items' properties, validation rules, and constraints. Custom content types' identifiers need to start with the ``c-`` prefix. Built-in content types can't be modified. @@ -356,32 +398,53 @@ def create_or_update( :param content_type_id: Content type identifier. :type content_type_id: str :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str + :param parameters: Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.ContentTypeContract :keyword callable cls: A custom type or function that will be passed the direct response :return: ContentTypeContract, or the result of cls(response) - :rtype: ~api_management_client.models.ContentTypeContract + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContentTypeContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ContentTypeContract] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ContentTypeContract') + else: + _json = None - 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, + api_version=api_version, + content_type=content_type, + json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -405,11 +468,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -435,11 +498,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -447,13 +515,20 @@ def delete( service_name=service_name, content_type_id=content_type_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -464,5 +539,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_delegation_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_delegation_settings_operations.py index 9e76c7575dde..2c263366fc75 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_delegation_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_delegation_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -67,31 +69,33 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -102,40 +106,41 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.PortalDelegationSettings] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -147,42 +152,43 @@ def build_create_or_update_request( service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.PortalDelegationSettings] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -195,55 +201,55 @@ def build_list_secrets_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation/listSecrets') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation/listSecrets") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DelegationSettingsOperations(object): - """DelegationSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DelegationSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`delegation_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get_entity_tag( @@ -263,23 +269,35 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -295,7 +313,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation"} # type: ignore @distributed_trace @@ -304,7 +322,7 @@ def get( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.PortalDelegationSettings": + ) -> _models.PortalDelegationSettings: """Get Delegation Settings for the Portal. :param resource_group_name: The name of the resource group. @@ -313,26 +331,38 @@ def get( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PortalDelegationSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalDelegationSettings + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalDelegationSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalDelegationSettings] request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -350,16 +380,16 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation"} # type: ignore @distributed_trace - def update( + def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, if_match: str, - parameters: "_models.PortalDelegationSettings", + parameters: _models.PortalDelegationSettings, **kwargs: Any ) -> None: """Update Delegation settings. @@ -372,19 +402,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update Delegation settings. - :type parameters: ~api_management_client.models.PortalDelegationSettings + :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(parameters, 'PortalDelegationSettings') @@ -392,15 +426,22 @@ def update( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -411,7 +452,7 @@ def update( if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation"} # type: ignore @distributed_trace @@ -419,10 +460,10 @@ def create_or_update( self, resource_group_name: str, service_name: str, - parameters: "_models.PortalDelegationSettings", + parameters: _models.PortalDelegationSettings, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PortalDelegationSettings": + ) -> _models.PortalDelegationSettings: """Create or Update Delegation settings. :param resource_group_name: The name of the resource group. @@ -430,22 +471,26 @@ def create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.PortalDelegationSettings + :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PortalDelegationSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalDelegationSettings + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalDelegationSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalDelegationSettings] _json = self._serialize.body(parameters, 'PortalDelegationSettings') @@ -453,15 +498,22 @@ def create_or_update( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -476,7 +528,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation"} # type: ignore @distributed_trace @@ -485,7 +537,7 @@ def list_secrets( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.PortalSettingValidationKeyContract": + ) -> _models.PortalSettingValidationKeyContract: """Gets the secret validation key of the DelegationSettings. :param resource_group_name: The name of the resource group. @@ -494,26 +546,38 @@ def list_secrets( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PortalSettingValidationKeyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSettingValidationKeyContract + :rtype: ~azure.mgmt.apimanagement.models.PortalSettingValidationKeyContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSettingValidationKeyContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalSettingValidationKeyContract] request = build_list_secrets_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_secrets.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -528,5 +592,5 @@ def list_secrets( return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation/listSecrets'} # type: ignore + list_secrets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_deleted_services_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_deleted_services_operations.py index 244b39f81a2f..42acb870a6d8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_deleted_services_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_deleted_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,12 +17,12 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -32,29 +33,31 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -65,31 +68,33 @@ def build_get_by_name_request( location: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}") # pylint: disable=line-too-long path_format_arguments = { "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "location": _SERIALIZER.url("location", location, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -100,92 +105,104 @@ def build_purge_request_initial( location: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}") # pylint: disable=line-too-long path_format_arguments = { "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "location": _SERIALIZER.url("location", location, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DeletedServicesOperations(object): - """DeletedServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeletedServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`deleted_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.DeletedServicesCollection"]: + ) -> 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[~api_management_client.models.DeletedServicesCollection] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.DeletedServicesCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedServicesCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedServicesCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -199,7 +216,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -213,7 +234,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices"} # type: ignore @distributed_trace def get_by_name( @@ -221,7 +242,7 @@ def get_by_name( service_name: str, location: str, **kwargs: Any - ) -> "_models.DeletedServiceContract": + ) -> _models.DeletedServiceContract: """Get soft-deleted Api Management Service by name. :param service_name: The name of the API Management service. @@ -230,26 +251,38 @@ def get_by_name( :type location: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedServiceContract, or the result of cls(response) - :rtype: ~api_management_client.models.DeletedServiceContract + :rtype: ~azure.mgmt.apimanagement.models.DeletedServiceContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedServiceContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedServiceContract] request = build_get_by_name_request( service_name=service_name, subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.get_by_name.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -264,7 +297,7 @@ def get_by_name( return deserialized - get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}'} # type: ignore + get_by_name.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}"} # type: ignore def _purge_initial( @@ -272,24 +305,36 @@ def _purge_initial( service_name: str, location: str, **kwargs: Any - ) -> Optional["_models.DeletedServiceContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DeletedServiceContract"]] + ) -> Optional[_models.DeletedServiceContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.DeletedServiceContract]] request = build_purge_request_initial( service_name=service_name, subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self._purge_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -305,7 +350,7 @@ def _purge_initial( return deserialized - _purge_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}'} # type: ignore + _purge_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}"} # type: ignore @distributed_trace @@ -314,7 +359,7 @@ def begin_purge( service_name: str, location: str, **kwargs: Any - ) -> LROPoller["_models.DeletedServiceContract"]: + ) -> LROPoller[_models.DeletedServiceContract]: """Purges Api Management Service (deletes it with no option to undelete). :param service_name: The name of the API Management service. @@ -331,35 +376,47 @@ def begin_purge( Retry-After header is present. :return: An instance of LROPoller that returns either DeletedServiceContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.DeletedServiceContract] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.DeletedServiceContract] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedServiceContract"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedServiceContract] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._purge_initial( + raw_result = self._purge_initial( # type: ignore service_name=service_name, location=location, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -368,7 +425,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_purge.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}'} # type: ignore + begin_purge.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_diagnostic_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_diagnostic_operations.py index 57df7d136ed8..5865091807dd 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_diagnostic_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_diagnostic_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -79,10 +81,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -90,21 +96,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -116,10 +120,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -127,21 +135,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -152,17 +158,20 @@ def build_create_or_update_request( diagnostic_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DiagnosticContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -170,25 +179,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -202,16 +209,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.DiagnosticContract] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -219,24 +229,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -252,10 +260,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -263,46 +275,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DiagnosticOperations(object): - """DiagnosticOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiagnosticOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`diagnostic` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -313,7 +321,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.DiagnosticCollection"]: + ) -> Iterable[_models.DiagnosticCollection]: """Lists all diagnostics of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -322,23 +330,29 @@ def list_by_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 |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DiagnosticCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.DiagnosticCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.DiagnosticCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -346,13 +360,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -360,13 +377,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -380,7 +400,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -394,7 +418,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics"} # type: ignore @distributed_trace def get_entity_tag( @@ -418,11 +442,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -430,12 +459,19 @@ def get_entity_tag( service_name=service_name, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -451,7 +487,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace @@ -461,7 +497,7 @@ def get( service_name: str, diagnostic_id: str, **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _models.DiagnosticContract: """Gets the details of the Diagnostic specified by its identifier. :param resource_group_name: The name of the resource group. @@ -473,14 +509,19 @@ def get( :type diagnostic_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticContract] request = build_get_request( @@ -488,12 +529,19 @@ def get( service_name=service_name, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -511,7 +559,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace @@ -520,10 +568,10 @@ def create_or_update( resource_group_name: str, service_name: str, diagnostic_id: str, - parameters: "_models.DiagnosticContract", + parameters: _models.DiagnosticContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _models.DiagnosticContract: """Creates a new Diagnostic or updates an existing one. :param resource_group_name: The name of the resource group. @@ -534,22 +582,26 @@ def create_or_update( service instance. :type diagnostic_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.DiagnosticContract + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticContract] _json = self._serialize.body(parameters, 'DiagnosticContract') @@ -558,15 +610,22 @@ def create_or_update( service_name=service_name, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -590,7 +649,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace @@ -600,9 +659,9 @@ def update( service_name: str, diagnostic_id: str, if_match: str, - parameters: "_models.DiagnosticContract", + parameters: _models.DiagnosticContract, **kwargs: Any - ) -> "_models.DiagnosticContract": + ) -> _models.DiagnosticContract: """Updates the details of the Diagnostic specified by its identifier. :param resource_group_name: The name of the resource group. @@ -616,19 +675,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Diagnostic Update parameters. - :type parameters: ~api_management_client.models.DiagnosticContract + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticContract, or the result of cls(response) - :rtype: ~api_management_client.models.DiagnosticContract + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticContract] _json = self._serialize.body(parameters, 'DiagnosticContract') @@ -637,15 +700,22 @@ def update( service_name=service_name, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -663,11 +733,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -692,11 +762,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -704,13 +779,20 @@ def delete( service_name=service_name, diagnostic_id=diagnostic_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -721,5 +803,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_email_template_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_email_template_operations.py index b4951001138c..0259eb916352 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_email_template_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_email_template_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -79,10 +81,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -90,21 +96,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -116,10 +120,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -127,21 +135,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -152,17 +158,20 @@ def build_create_or_update_request( template_name: Union[str, "_models.TemplateName"], subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.EmailTemplateUpdateParameters] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -170,25 +179,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -202,16 +209,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.EmailTemplateUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -219,24 +229,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -252,10 +260,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -263,46 +275,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class EmailTemplateOperations(object): - """EmailTemplateOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class EmailTemplateOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`email_template` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -313,7 +321,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.EmailTemplateCollection"]: + ) -> Iterable[_models.EmailTemplateCollection]: """Gets all email templates. :param resource_group_name: The name of the resource group. @@ -322,23 +330,29 @@ def list_by_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 |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EmailTemplateCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.EmailTemplateCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.EmailTemplateCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EmailTemplateCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EmailTemplateCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -346,13 +360,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -360,13 +377,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -380,7 +400,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -394,7 +418,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates"} # type: ignore @distributed_trace def get_entity_tag( @@ -411,17 +435,22 @@ def get_entity_tag( :param service_name: The name of the API Management service. :type service_name: str :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName :keyword callable cls: A custom type or function that will be passed the direct response :return: bool, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -429,12 +458,19 @@ def get_entity_tag( service_name=service_name, template_name=template_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -450,7 +486,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # type: ignore @distributed_trace @@ -460,7 +496,7 @@ def get( service_name: str, template_name: Union[str, "_models.TemplateName"], **kwargs: Any - ) -> "_models.EmailTemplateContract": + ) -> _models.EmailTemplateContract: """Gets the details of the email template specified by its identifier. :param resource_group_name: The name of the resource group. @@ -468,17 +504,22 @@ def get( :param service_name: The name of the API Management service. :type service_name: str :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName :keyword callable cls: A custom type or function that will be passed the direct response :return: EmailTemplateContract, or the result of cls(response) - :rtype: ~api_management_client.models.EmailTemplateContract + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EmailTemplateContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EmailTemplateContract] request = build_get_request( @@ -486,12 +527,19 @@ def get( service_name=service_name, template_name=template_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -509,7 +557,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # type: ignore @distributed_trace @@ -518,10 +566,10 @@ def create_or_update( resource_group_name: str, service_name: str, template_name: Union[str, "_models.TemplateName"], - parameters: "_models.EmailTemplateUpdateParameters", + parameters: _models.EmailTemplateUpdateParameters, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.EmailTemplateContract": + ) -> _models.EmailTemplateContract: """Updates an Email Template. :param resource_group_name: The name of the resource group. @@ -529,24 +577,28 @@ def create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName :param parameters: Email Template update parameters. - :type parameters: ~api_management_client.models.EmailTemplateUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: EmailTemplateContract, or the result of cls(response) - :rtype: ~api_management_client.models.EmailTemplateContract + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EmailTemplateContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.EmailTemplateContract] _json = self._serialize.body(parameters, 'EmailTemplateUpdateParameters') @@ -555,15 +607,22 @@ def create_or_update( service_name=service_name, template_name=template_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -582,7 +641,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # type: ignore @distributed_trace @@ -592,9 +651,9 @@ def update( service_name: str, template_name: Union[str, "_models.TemplateName"], if_match: str, - parameters: "_models.EmailTemplateUpdateParameters", + parameters: _models.EmailTemplateUpdateParameters, **kwargs: Any - ) -> "_models.EmailTemplateContract": + ) -> _models.EmailTemplateContract: """Updates API Management email template. :param resource_group_name: The name of the resource group. @@ -602,24 +661,28 @@ def update( :param service_name: The name of the API Management service. :type service_name: str :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.EmailTemplateUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: EmailTemplateContract, or the result of cls(response) - :rtype: ~api_management_client.models.EmailTemplateContract + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EmailTemplateContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.EmailTemplateContract] _json = self._serialize.body(parameters, 'EmailTemplateUpdateParameters') @@ -628,15 +691,22 @@ def update( service_name=service_name, template_name=template_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -654,11 +724,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -673,7 +743,7 @@ def delete( :param service_name: The name of the API Management service. :type service_name: str :param template_name: Email Template Name Identifier. - :type template_name: str or ~api_management_client.models.TemplateName + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str @@ -682,11 +752,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -694,13 +769,20 @@ def delete( service_name=service_name, template_name=template_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -711,5 +793,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_api_operations.py index d7901e83c425..71a4d3bd38ee 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_api_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_api_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -38,10 +38,14 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -49,27 +53,25 @@ def build_list_by_service_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -82,10 +84,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -94,21 +100,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -120,16 +124,19 @@ def build_create_or_update_request( api_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AssociationContract] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -138,23 +145,21 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -169,10 +174,14 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -181,45 +190,41 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class GatewayApiOperations(object): - """GatewayApiOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GatewayApiOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`gateway_api` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -231,7 +236,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ApiCollection"]: + ) -> Iterable[_models.ApiCollection]: """Lists a collection of the APIs associated with a gateway. :param resource_group_name: The name of the resource group. @@ -243,22 +248,28 @@ def list_by_service( :type gateway_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ApiCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -267,13 +278,16 @@ def prepare_request(next_link=None): service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -282,13 +296,16 @@ def prepare_request(next_link=None): service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -302,7 +319,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -316,7 +337,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis"} # type: ignore @distributed_trace def get_entity_tag( @@ -343,11 +364,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -356,12 +382,19 @@ def get_entity_tag( gateway_id=gateway_id, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -377,7 +410,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}"} # type: ignore @distributed_trace @@ -387,9 +420,9 @@ def create_or_update( service_name: str, gateway_id: str, api_id: str, - parameters: Optional["_models.AssociationContract"] = None, + parameters: Optional[_models.AssociationContract] = None, **kwargs: Any - ) -> "_models.ApiContract": + ) -> _models.ApiContract: """Adds an API to the specified Gateway. :param resource_group_name: The name of the resource group. @@ -401,20 +434,24 @@ def create_or_update( :type gateway_id: str :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param parameters: - :type parameters: ~api_management_client.models.AssociationContract + :param parameters: Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.AssociationContract :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiContract + :rtype: ~azure.mgmt.apimanagement.models.ApiContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiContract] if parameters is not None: _json = self._serialize.body(parameters, 'AssociationContract') @@ -427,14 +464,21 @@ def create_or_update( gateway_id=gateway_id, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -453,11 +497,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -481,11 +525,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -494,12 +543,19 @@ def delete( gateway_id=gateway_id, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -510,5 +566,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_certificate_authority_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_certificate_authority_operations.py index 60bdc569e414..a5c790750024 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_certificate_authority_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_certificate_authority_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -38,10 +38,14 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -49,27 +53,25 @@ def build_list_by_service_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -82,10 +84,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -94,21 +100,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -121,10 +125,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -133,21 +141,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -159,17 +165,20 @@ def build_create_or_update_request( certificate_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.GatewayCertificateAuthorityContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -178,25 +187,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -213,10 +220,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -225,46 +236,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class GatewayCertificateAuthorityOperations(object): - """GatewayCertificateAuthorityOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GatewayCertificateAuthorityOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`gateway_certificate_authority` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -276,7 +283,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.GatewayCertificateAuthorityCollection"]: + ) -> Iterable[_models.GatewayCertificateAuthorityCollection]: """Lists the collection of Certificate Authorities for the specified Gateway entity. :param resource_group_name: The name of the resource group. @@ -288,24 +295,29 @@ def list_by_service( :type gateway_id: str :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | - filter | eq, ne | |
. + filter | eq, ne | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GatewayCertificateAuthorityCollection or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~api_management_client.models.GatewayCertificateAuthorityCollection] + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCertificateAuthorityCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayCertificateAuthorityCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -314,13 +326,16 @@ def prepare_request(next_link=None): service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -329,13 +344,16 @@ def prepare_request(next_link=None): service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -349,7 +367,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -363,7 +385,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities"} # type: ignore @distributed_trace def get_entity_tag( @@ -391,11 +413,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -404,12 +431,19 @@ def get_entity_tag( gateway_id=gateway_id, certificate_id=certificate_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -425,7 +459,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}"} # type: ignore @distributed_trace @@ -436,7 +470,7 @@ def get( gateway_id: str, certificate_id: str, **kwargs: Any - ) -> "_models.GatewayCertificateAuthorityContract": + ) -> _models.GatewayCertificateAuthorityContract: """Get assigned Gateway Certificate Authority details. :param resource_group_name: The name of the resource group. @@ -451,14 +485,19 @@ def get( :type certificate_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GatewayCertificateAuthorityContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayCertificateAuthorityContract + :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCertificateAuthorityContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayCertificateAuthorityContract] request = build_get_request( @@ -467,12 +506,19 @@ def get( gateway_id=gateway_id, certificate_id=certificate_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -490,7 +536,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}"} # type: ignore @distributed_trace @@ -500,10 +546,10 @@ def create_or_update( service_name: str, gateway_id: str, certificate_id: str, - parameters: "_models.GatewayCertificateAuthorityContract", + parameters: _models.GatewayCertificateAuthorityContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.GatewayCertificateAuthorityContract": + ) -> _models.GatewayCertificateAuthorityContract: """Assign Certificate entity to Gateway entity as Certificate Authority. :param resource_group_name: The name of the resource group. @@ -517,22 +563,26 @@ def create_or_update( Management service instance. :type certificate_id: str :param parameters: - :type parameters: ~api_management_client.models.GatewayCertificateAuthorityContract + :type parameters: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GatewayCertificateAuthorityContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayCertificateAuthorityContract + :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCertificateAuthorityContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayCertificateAuthorityContract] _json = self._serialize.body(parameters, 'GatewayCertificateAuthorityContract') @@ -542,15 +592,22 @@ def create_or_update( gateway_id=gateway_id, certificate_id=certificate_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -574,11 +631,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -607,11 +664,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -620,13 +682,20 @@ def delete( gateway_id=gateway_id, certificate_id=certificate_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -637,5 +706,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_hostname_configuration_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_hostname_configuration_operations.py index e7a536356bf1..b98638c69eb0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_hostname_configuration_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_hostname_configuration_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -38,10 +38,14 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -49,27 +53,25 @@ def build_list_by_service_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -82,10 +84,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -94,21 +100,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -121,10 +125,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -133,21 +141,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -159,17 +165,20 @@ def build_create_or_update_request( hc_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.GatewayHostnameConfigurationContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -178,25 +187,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -213,10 +220,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -225,46 +236,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class GatewayHostnameConfigurationOperations(object): - """GatewayHostnameConfigurationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GatewayHostnameConfigurationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`gateway_hostname_configuration` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -276,7 +283,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.GatewayHostnameConfigurationCollection"]: + ) -> Iterable[_models.GatewayHostnameConfigurationCollection]: """Lists the collection of hostname configurations for the specified gateway. :param resource_group_name: The name of the resource group. @@ -289,24 +296,30 @@ def list_by_service( :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| hostname - | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GatewayHostnameConfigurationCollection or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~api_management_client.models.GatewayHostnameConfigurationCollection] + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayHostnameConfigurationCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayHostnameConfigurationCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -315,13 +328,16 @@ def prepare_request(next_link=None): service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -330,13 +346,16 @@ def prepare_request(next_link=None): service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -350,7 +369,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -364,7 +387,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations"} # type: ignore @distributed_trace def get_entity_tag( @@ -393,11 +416,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -406,12 +434,19 @@ def get_entity_tag( gateway_id=gateway_id, hc_id=hc_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -427,7 +462,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}"} # type: ignore @distributed_trace @@ -438,7 +473,7 @@ def get( gateway_id: str, hc_id: str, **kwargs: Any - ) -> "_models.GatewayHostnameConfigurationContract": + ) -> _models.GatewayHostnameConfigurationContract: """Get details of a hostname configuration. :param resource_group_name: The name of the resource group. @@ -453,14 +488,19 @@ def get( :type hc_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GatewayHostnameConfigurationContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayHostnameConfigurationContract + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayHostnameConfigurationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayHostnameConfigurationContract] request = build_get_request( @@ -469,12 +509,19 @@ def get( gateway_id=gateway_id, hc_id=hc_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -492,7 +539,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}"} # type: ignore @distributed_trace @@ -502,10 +549,10 @@ def create_or_update( service_name: str, gateway_id: str, hc_id: str, - parameters: "_models.GatewayHostnameConfigurationContract", + parameters: _models.GatewayHostnameConfigurationContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.GatewayHostnameConfigurationContract": + ) -> _models.GatewayHostnameConfigurationContract: """Creates of updates hostname configuration for a Gateway. :param resource_group_name: The name of the resource group. @@ -519,22 +566,26 @@ def create_or_update( Gateway entity. :type hc_id: str :param parameters: - :type parameters: ~api_management_client.models.GatewayHostnameConfigurationContract + :type parameters: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GatewayHostnameConfigurationContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayHostnameConfigurationContract + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayHostnameConfigurationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayHostnameConfigurationContract] _json = self._serialize.body(parameters, 'GatewayHostnameConfigurationContract') @@ -544,15 +595,22 @@ def create_or_update( gateway_id=gateway_id, hc_id=hc_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -576,11 +634,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -609,11 +667,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -622,13 +685,20 @@ def delete( gateway_id=gateway_id, hc_id=hc_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -639,5 +709,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_operations.py index 784480f5d4c5..51e38b7e2a0a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -79,10 +81,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -90,21 +96,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -116,10 +120,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -127,21 +135,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -152,17 +158,20 @@ def build_create_or_update_request( gateway_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.GatewayContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -170,25 +179,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -202,16 +209,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.GatewayContract] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -219,24 +229,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -252,10 +260,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -263,22 +275,20 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -290,10 +300,14 @@ def build_list_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listKeys") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -301,21 +315,19 @@ def build_list_keys_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -326,16 +338,19 @@ def build_regenerate_key_request( gateway_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.GatewayKeyRegenerationRequestContract] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -343,23 +358,21 @@ def build_regenerate_key_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -372,16 +385,19 @@ def build_generate_token_request( gateway_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.GatewayTokenRequestContract] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/generateToken') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/generateToken") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -389,49 +405,45 @@ def build_generate_token_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class GatewayOperations(object): - """GatewayOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GatewayOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`gateway` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -442,7 +454,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.GatewayCollection"]: + ) -> Iterable[_models.GatewayCollection]: """Lists a collection of gateways registered with service instance. :param resource_group_name: The name of the resource group. @@ -454,22 +466,27 @@ def list_by_service( filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| region | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
. + |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GatewayCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.GatewayCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GatewayCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -477,13 +494,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -491,13 +511,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -511,7 +534,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -525,7 +552,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways"} # type: ignore @distributed_trace def get_entity_tag( @@ -549,11 +576,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -561,12 +593,19 @@ def get_entity_tag( service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -582,7 +621,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # type: ignore @distributed_trace @@ -592,7 +631,7 @@ def get( service_name: str, gateway_id: str, **kwargs: Any - ) -> "_models.GatewayContract": + ) -> _models.GatewayContract: """Gets the details of the Gateway specified by its identifier. :param resource_group_name: The name of the resource group. @@ -604,14 +643,19 @@ def get( :type gateway_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GatewayContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayContract + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayContract] request = build_get_request( @@ -619,12 +663,19 @@ def get( service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -642,7 +693,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # type: ignore @distributed_trace @@ -651,10 +702,10 @@ def create_or_update( resource_group_name: str, service_name: str, gateway_id: str, - parameters: "_models.GatewayContract", + parameters: _models.GatewayContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.GatewayContract": + ) -> _models.GatewayContract: """Creates or updates a Gateway to be used in Api Management instance. :param resource_group_name: The name of the resource group. @@ -665,22 +716,26 @@ def create_or_update( service instance. Must not have value 'managed'. :type gateway_id: str :param parameters: - :type parameters: ~api_management_client.models.GatewayContract + :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GatewayContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayContract + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayContract] _json = self._serialize.body(parameters, 'GatewayContract') @@ -689,15 +744,22 @@ def create_or_update( service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -721,7 +783,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # type: ignore @distributed_trace @@ -731,9 +793,9 @@ def update( service_name: str, gateway_id: str, if_match: str, - parameters: "_models.GatewayContract", + parameters: _models.GatewayContract, **kwargs: Any - ) -> "_models.GatewayContract": + ) -> _models.GatewayContract: """Updates the details of the gateway specified by its identifier. :param resource_group_name: The name of the resource group. @@ -747,19 +809,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: - :type parameters: ~api_management_client.models.GatewayContract + :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract :keyword callable cls: A custom type or function that will be passed the direct response :return: GatewayContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayContract + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayContract] _json = self._serialize.body(parameters, 'GatewayContract') @@ -768,15 +834,22 @@ def update( service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -794,11 +867,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -823,11 +896,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -835,13 +913,20 @@ def delete( service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -852,7 +937,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}"} # type: ignore @distributed_trace @@ -862,7 +947,7 @@ def list_keys( service_name: str, gateway_id: str, **kwargs: Any - ) -> "_models.GatewayKeysContract": + ) -> _models.GatewayKeysContract: """Retrieves gateway keys. :param resource_group_name: The name of the resource group. @@ -874,14 +959,19 @@ def list_keys( :type gateway_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GatewayKeysContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayKeysContract + :rtype: ~azure.mgmt.apimanagement.models.GatewayKeysContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayKeysContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayKeysContract] request = build_list_keys_request( @@ -889,12 +979,19 @@ def list_keys( service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -912,16 +1009,16 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listKeys"} # type: ignore @distributed_trace - def regenerate_key( + def regenerate_key( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, gateway_id: str, - parameters: "_models.GatewayKeyRegenerationRequestContract", + parameters: _models.GatewayKeyRegenerationRequestContract, **kwargs: Any ) -> None: """Regenerates specified gateway key invalidating any tokens created with it. @@ -934,19 +1031,23 @@ def regenerate_key( service instance. Must not have value 'managed'. :type gateway_id: str :param parameters: - :type parameters: ~api_management_client.models.GatewayKeyRegenerationRequestContract + :type parameters: ~azure.mgmt.apimanagement.models.GatewayKeyRegenerationRequestContract :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(parameters, 'GatewayKeyRegenerationRequestContract') @@ -955,14 +1056,21 @@ def regenerate_key( service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -973,7 +1081,7 @@ def regenerate_key( if cls: return cls(pipeline_response, None, {}) - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/regenerateKey"} # type: ignore @distributed_trace @@ -982,9 +1090,9 @@ def generate_token( resource_group_name: str, service_name: str, gateway_id: str, - parameters: "_models.GatewayTokenRequestContract", + parameters: _models.GatewayTokenRequestContract, **kwargs: Any - ) -> "_models.GatewayTokenContract": + ) -> _models.GatewayTokenContract: """Gets the Shared Access Authorization Token for the gateway. :param resource_group_name: The name of the resource group. @@ -995,19 +1103,23 @@ def generate_token( service instance. Must not have value 'managed'. :type gateway_id: str :param parameters: - :type parameters: ~api_management_client.models.GatewayTokenRequestContract + :type parameters: ~azure.mgmt.apimanagement.models.GatewayTokenRequestContract :keyword callable cls: A custom type or function that will be passed the direct response :return: GatewayTokenContract, or the result of cls(response) - :rtype: ~api_management_client.models.GatewayTokenContract + :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewayTokenContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GatewayTokenContract] _json = self._serialize.body(parameters, 'GatewayTokenRequestContract') @@ -1016,14 +1128,21 @@ def generate_token( service_name=service_name, gateway_id=gateway_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.generate_token.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1038,5 +1157,5 @@ def generate_token( return deserialized - generate_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/generateToken'} # type: ignore + generate_token.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/generateToken"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_global_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_global_schema_operations.py index 4f77dca140ca..c1641a24b898 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_global_schema_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_global_schema_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -39,37 +39,39 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -81,10 +83,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -92,21 +98,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -118,10 +122,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -129,21 +137,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -154,17 +160,20 @@ def build_create_or_update_request_initial( schema_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.GlobalSchemaContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -172,25 +181,23 @@ def build_create_or_update_request_initial( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -206,10 +213,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -217,46 +228,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **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. +class GlobalSchemaOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`global_schema` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -267,7 +274,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.GlobalSchemaCollection"]: + ) -> Iterable[_models.GlobalSchemaCollection]: """Lists a collection of schemas registered with service instance. :param resource_group_name: The name of the resource group. @@ -276,23 +283,29 @@ def list_by_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 |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GlobalSchemaCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.GlobalSchemaCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GlobalSchemaCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GlobalSchemaCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GlobalSchemaCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -300,13 +313,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -314,13 +330,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -334,7 +353,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -348,7 +371,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas"} # type: ignore @distributed_trace def get_entity_tag( @@ -372,11 +395,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -384,12 +412,19 @@ def get_entity_tag( service_name=service_name, schema_id=schema_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,7 +440,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # type: ignore @distributed_trace @@ -415,7 +450,7 @@ def get( service_name: str, schema_id: str, **kwargs: Any - ) -> "_models.GlobalSchemaContract": + ) -> _models.GlobalSchemaContract: """Gets the details of the Schema specified by its identifier. :param resource_group_name: The name of the resource group. @@ -427,14 +462,19 @@ def get( :type schema_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GlobalSchemaContract, or the result of cls(response) - :rtype: ~api_management_client.models.GlobalSchemaContract + :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GlobalSchemaContract] request = build_get_request( @@ -442,12 +482,19 @@ def get( service_name=service_name, schema_id=schema_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -465,7 +512,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # type: ignore def _create_or_update_initial( @@ -473,17 +520,21 @@ def _create_or_update_initial( resource_group_name: str, service_name: str, schema_id: str, - parameters: "_models.GlobalSchemaContract", + parameters: _models.GlobalSchemaContract, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.GlobalSchemaContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GlobalSchemaContract"]] + ) -> Optional[_models.GlobalSchemaContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.GlobalSchemaContract]] _json = self._serialize.body(parameters, 'GlobalSchemaContract') @@ -492,15 +543,22 @@ def _create_or_update_initial( service_name=service_name, schema_id=schema_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -524,7 +582,7 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # type: ignore @distributed_trace @@ -533,10 +591,10 @@ def begin_create_or_update( resource_group_name: str, service_name: str, schema_id: str, - parameters: "_models.GlobalSchemaContract", + parameters: _models.GlobalSchemaContract, if_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.GlobalSchemaContract"]: + ) -> LROPoller[_models.GlobalSchemaContract]: """Creates new or updates existing specified Schema of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -547,9 +605,9 @@ def begin_create_or_update( instance. :type schema_id: str :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.GlobalSchemaContract + :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. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -561,26 +619,33 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either GlobalSchemaContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.GlobalSchemaContract] + :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"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GlobalSchemaContract] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, schema_id=schema_id, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -596,8 +661,14 @@ def get_long_running_output(pipeline_response): 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() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -606,13 +677,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -637,11 +707,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -649,13 +724,20 @@ def delete( service_name=service_name, schema_id=schema_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -666,5 +748,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_operations.py index bc36b3954f2e..65f95af0a923 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -79,10 +81,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -90,21 +96,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -116,10 +120,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -127,21 +135,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -152,17 +158,20 @@ def build_create_or_update_request( group_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.GroupCreateParameters] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -170,25 +179,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -202,16 +209,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.GroupUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -219,24 +229,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -252,10 +260,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -263,46 +275,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class GroupOperations(object): - """GroupOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`group` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -313,7 +321,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.GroupCollection"]: + ) -> Iterable[_models.GroupCollection]: """Lists a collection of groups defined within a service instance. :param resource_group_name: The name of the resource group. @@ -325,22 +333,27 @@ def list_by_service( filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| externalId | filter | eq | |
. + endswith |
| externalId | filter | eq | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GroupCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.GroupCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GroupCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GroupCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -348,13 +361,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -362,13 +378,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -382,7 +401,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -396,7 +419,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups"} # type: ignore @distributed_trace def get_entity_tag( @@ -420,11 +443,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -432,12 +460,19 @@ def get_entity_tag( service_name=service_name, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -453,7 +488,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # type: ignore @distributed_trace @@ -463,7 +498,7 @@ def get( service_name: str, group_id: str, **kwargs: Any - ) -> "_models.GroupContract": + ) -> _models.GroupContract: """Gets the details of the group specified by its identifier. :param resource_group_name: The name of the resource group. @@ -475,14 +510,19 @@ def get( :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GroupContract, or the result of cls(response) - :rtype: ~api_management_client.models.GroupContract + :rtype: ~azure.mgmt.apimanagement.models.GroupContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GroupContract] request = build_get_request( @@ -490,12 +530,19 @@ def get( service_name=service_name, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -513,7 +560,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # type: ignore @distributed_trace @@ -522,10 +569,10 @@ def create_or_update( resource_group_name: str, service_name: str, group_id: str, - parameters: "_models.GroupCreateParameters", + parameters: _models.GroupCreateParameters, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.GroupContract": + ) -> _models.GroupContract: """Creates or Updates a group. :param resource_group_name: The name of the resource group. @@ -536,22 +583,26 @@ def create_or_update( instance. :type group_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.GroupCreateParameters + :type parameters: ~azure.mgmt.apimanagement.models.GroupCreateParameters :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GroupContract, or the result of cls(response) - :rtype: ~api_management_client.models.GroupContract + :rtype: ~azure.mgmt.apimanagement.models.GroupContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GroupContract] _json = self._serialize.body(parameters, 'GroupCreateParameters') @@ -560,15 +611,22 @@ def create_or_update( service_name=service_name, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -592,7 +650,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # type: ignore @distributed_trace @@ -602,9 +660,9 @@ def update( service_name: str, group_id: str, if_match: str, - parameters: "_models.GroupUpdateParameters", + parameters: _models.GroupUpdateParameters, **kwargs: Any - ) -> "_models.GroupContract": + ) -> _models.GroupContract: """Updates the details of the group specified by its identifier. :param resource_group_name: The name of the resource group. @@ -618,19 +676,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.GroupUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.GroupUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: GroupContract, or the result of cls(response) - :rtype: ~api_management_client.models.GroupContract + :rtype: ~azure.mgmt.apimanagement.models.GroupContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GroupContract] _json = self._serialize.body(parameters, 'GroupUpdateParameters') @@ -639,15 +701,22 @@ def update( service_name=service_name, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -665,11 +734,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -694,11 +763,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -706,13 +780,20 @@ def delete( service_name=service_name, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -723,5 +804,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_user_operations.py index 76fb5f0a1397..681ac91379a4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_user_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_user_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -37,10 +38,14 @@ def build_list_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -48,27 +53,25 @@ def build_list_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -81,10 +84,14 @@ def build_check_entity_exists_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -93,21 +100,19 @@ def build_check_entity_exists_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -120,10 +125,14 @@ def build_create_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -132,21 +141,19 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -159,10 +166,14 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -171,45 +182,41 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class GroupUserOperations(object): - """GroupUserOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GroupUserOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`group_user` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -221,7 +228,7 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.UserCollection"]: + ) -> Iterable[_models.UserCollection]: """Lists a collection of user entities associated with the group. :param resource_group_name: The name of the resource group. @@ -238,22 +245,27 @@ def list( lastName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| email | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| registrationDate | filter | ge, le, eq, ne, gt, lt | |
| note | filter | ge, - le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either UserCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.UserCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.UserCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -262,13 +274,16 @@ def prepare_request(next_link=None): service_name=service_name, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -277,13 +292,16 @@ def prepare_request(next_link=None): service_name=service_name, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -297,7 +315,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -311,7 +333,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users"} # type: ignore @distributed_trace def check_entity_exists( @@ -338,11 +360,16 @@ def check_entity_exists( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_check_entity_exists_request( @@ -351,12 +378,19 @@ def check_entity_exists( group_id=group_id, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.check_entity_exists.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -368,7 +402,7 @@ def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} # type: ignore + check_entity_exists.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}"} # type: ignore @distributed_trace @@ -379,7 +413,7 @@ def create( group_id: str, user_id: str, **kwargs: Any - ) -> "_models.UserContract": + ) -> _models.UserContract: """Add existing user to existing group. :param resource_group_name: The name of the resource group. @@ -393,14 +427,19 @@ def create( :type user_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: UserContract, or the result of cls(response) - :rtype: ~api_management_client.models.UserContract + :rtype: ~azure.mgmt.apimanagement.models.UserContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserContract] request = build_create_request( @@ -409,12 +448,19 @@ def create( group_id=group_id, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -433,11 +479,11 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -461,11 +507,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -474,12 +525,19 @@ def delete( group_id=group_id, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -490,5 +548,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_identity_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_identity_provider_operations.py index 8270aa523bf1..646d0bf49684 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_identity_provider_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_identity_provider_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_by_service_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +71,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -80,21 +86,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -106,10 +110,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -117,21 +125,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -142,17 +148,20 @@ def build_create_or_update_request( identity_provider_name: Union[str, "_models.IdentityProviderType"], subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.IdentityProviderCreateContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -160,25 +169,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -192,16 +199,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.IdentityProviderUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -209,24 +219,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -242,10 +250,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -253,22 +265,20 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -280,10 +290,14 @@ def build_list_secrets_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}/listSecrets') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}/listSecrets") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -291,45 +305,41 @@ def build_list_secrets_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class IdentityProviderOperations(object): - """IdentityProviderOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IdentityProviderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`identity_provider` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -337,7 +347,7 @@ def list_by_service( resource_group_name: str, service_name: str, **kwargs: Any - ) -> Iterable["_models.IdentityProviderList"]: + ) -> 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. @@ -347,14 +357,19 @@ def list_by_service( :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.paging.ItemPaged[~api_management_client.models.IdentityProviderList] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IdentityProviderList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IdentityProviderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IdentityProviderList] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -362,10 +377,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -373,10 +391,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -390,7 +411,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -404,7 +429,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders"} # type: ignore @distributed_trace def get_entity_tag( @@ -421,17 +446,22 @@ def get_entity_tag( :param service_name: The name of the API Management service. :type service_name: str :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType :keyword callable cls: A custom type or function that will be passed the direct response :return: bool, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -439,12 +469,19 @@ def get_entity_tag( service_name=service_name, identity_provider_name=identity_provider_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -460,7 +497,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # type: ignore @distributed_trace @@ -470,7 +507,7 @@ def get( service_name: str, identity_provider_name: Union[str, "_models.IdentityProviderType"], **kwargs: Any - ) -> "_models.IdentityProviderContract": + ) -> _models.IdentityProviderContract: """Gets the configuration details of the identity Provider configured in specified service instance. @@ -479,17 +516,22 @@ def get( :param service_name: The name of the API Management service. :type service_name: str :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType :keyword callable cls: A custom type or function that will be passed the direct response :return: IdentityProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.IdentityProviderContract + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IdentityProviderContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IdentityProviderContract] request = build_get_request( @@ -497,12 +539,19 @@ def get( service_name=service_name, identity_provider_name=identity_provider_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -520,7 +569,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # type: ignore @distributed_trace @@ -529,10 +578,10 @@ def create_or_update( resource_group_name: str, service_name: str, identity_provider_name: Union[str, "_models.IdentityProviderType"], - parameters: "_models.IdentityProviderCreateContract", + parameters: _models.IdentityProviderCreateContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.IdentityProviderContract": + ) -> _models.IdentityProviderContract: """Creates or Updates the IdentityProvider configuration. :param resource_group_name: The name of the resource group. @@ -540,24 +589,28 @@ def create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType :param parameters: Create parameters. - :type parameters: ~api_management_client.models.IdentityProviderCreateContract + :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderCreateContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: IdentityProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.IdentityProviderContract + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IdentityProviderContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.IdentityProviderContract] _json = self._serialize.body(parameters, 'IdentityProviderCreateContract') @@ -566,15 +619,22 @@ def create_or_update( service_name=service_name, identity_provider_name=identity_provider_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -598,7 +658,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # type: ignore @distributed_trace @@ -608,9 +668,9 @@ def update( service_name: str, identity_provider_name: Union[str, "_models.IdentityProviderType"], if_match: str, - parameters: "_models.IdentityProviderUpdateParameters", + parameters: _models.IdentityProviderUpdateParameters, **kwargs: Any - ) -> "_models.IdentityProviderContract": + ) -> _models.IdentityProviderContract: """Updates an existing IdentityProvider configuration. :param resource_group_name: The name of the resource group. @@ -618,24 +678,28 @@ def update( :param service_name: The name of the API Management service. :type service_name: str :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.IdentityProviderUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: IdentityProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.IdentityProviderContract + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IdentityProviderContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.IdentityProviderContract] _json = self._serialize.body(parameters, 'IdentityProviderUpdateParameters') @@ -644,15 +708,22 @@ def update( service_name=service_name, identity_provider_name=identity_provider_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -670,11 +741,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -689,7 +760,7 @@ def delete( :param service_name: The name of the API Management service. :type service_name: str :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str @@ -698,11 +769,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -710,13 +786,20 @@ def delete( service_name=service_name, identity_provider_name=identity_provider_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -727,7 +810,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}"} # type: ignore @distributed_trace @@ -737,7 +820,7 @@ def list_secrets( service_name: str, identity_provider_name: Union[str, "_models.IdentityProviderType"], **kwargs: Any - ) -> "_models.ClientSecretContract": + ) -> _models.ClientSecretContract: """Gets the client secret details of the Identity Provider. :param resource_group_name: The name of the resource group. @@ -745,17 +828,22 @@ def list_secrets( :param service_name: The name of the API Management service. :type service_name: str :param identity_provider_name: Identity Provider Type identifier. - :type identity_provider_name: str or ~api_management_client.models.IdentityProviderType + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType :keyword callable cls: A custom type or function that will be passed the direct response :return: ClientSecretContract, or the result of cls(response) - :rtype: ~api_management_client.models.ClientSecretContract + :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClientSecretContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ClientSecretContract] request = build_list_secrets_request( @@ -763,12 +851,19 @@ def list_secrets( service_name=service_name, identity_provider_name=identity_provider_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_secrets.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -786,5 +881,5 @@ def list_secrets( return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}/listSecrets'} # type: ignore + list_secrets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_issue_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_issue_operations.py index 7f1d97aacc24..ce73a1bceb1e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_issue_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_issue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -36,37 +37,39 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -78,10 +81,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues/{issueId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues/{issueId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -89,45 +96,41 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class IssueOperations(object): - """IssueOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IssueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`issue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -138,7 +141,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.IssueCollection"]: + ) -> Iterable[_models.IssueCollection]: """Lists a collection of issues in the specified service instance. :param resource_group_name: The name of the resource group. @@ -152,22 +155,27 @@ def list_by_service( filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| authorName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| state | filter | eq | |
. + endswith |
| state | filter | eq | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either IssueCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.IssueCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IssueCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -175,13 +183,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -189,13 +200,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -209,7 +223,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -223,7 +241,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues"} # type: ignore @distributed_trace def get( @@ -232,7 +250,7 @@ def get( service_name: str, issue_id: str, **kwargs: Any - ) -> "_models.IssueContract": + ) -> _models.IssueContract: """Gets API Management issue details. :param resource_group_name: The name of the resource group. @@ -244,14 +262,19 @@ def get( :type issue_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: IssueContract, or the result of cls(response) - :rtype: ~api_management_client.models.IssueContract + :rtype: ~azure.mgmt.apimanagement.models.IssueContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IssueContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IssueContract] request = build_get_request( @@ -259,12 +282,19 @@ def get( service_name=service_name, issue_id=issue_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -282,5 +312,5 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues/{issueId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues/{issueId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_logger_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_logger_operations.py index 7c176f575994..f60ccb996416 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_logger_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_logger_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -79,10 +81,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -90,21 +96,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -116,10 +120,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -127,21 +135,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -152,17 +158,20 @@ def build_create_or_update_request( logger_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LoggerContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -170,25 +179,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -202,16 +209,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.LoggerUpdateContract] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -219,24 +229,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -252,10 +260,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -263,46 +275,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class LoggerOperations(object): - """LoggerOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LoggerOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`logger` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -313,7 +321,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.LoggerCollection"]: + ) -> Iterable[_models.LoggerCollection]: """Lists a collection of loggers in the specified service instance. :param resource_group_name: The name of the resource group. @@ -325,22 +333,27 @@ def list_by_service( filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| loggerType | filter | eq | |
| resourceId | filter | ge, le, eq, ne, gt, lt | - substringof, contains, startswith, endswith |
. + substringof, contains, startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LoggerCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.LoggerCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.LoggerCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LoggerCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LoggerCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -348,13 +361,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -362,13 +378,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -382,7 +401,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -396,7 +419,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers"} # type: ignore @distributed_trace def get_entity_tag( @@ -419,11 +442,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -431,12 +459,19 @@ def get_entity_tag( service_name=service_name, logger_id=logger_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -452,7 +487,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # type: ignore @distributed_trace @@ -462,7 +497,7 @@ def get( service_name: str, logger_id: str, **kwargs: Any - ) -> "_models.LoggerContract": + ) -> _models.LoggerContract: """Gets the details of the logger specified by its identifier. :param resource_group_name: The name of the resource group. @@ -473,14 +508,19 @@ def get( :type logger_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LoggerContract, or the result of cls(response) - :rtype: ~api_management_client.models.LoggerContract + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LoggerContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LoggerContract] request = build_get_request( @@ -488,12 +528,19 @@ def get( service_name=service_name, logger_id=logger_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -511,7 +558,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # type: ignore @distributed_trace @@ -520,10 +567,10 @@ def create_or_update( resource_group_name: str, service_name: str, logger_id: str, - parameters: "_models.LoggerContract", + parameters: _models.LoggerContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.LoggerContract": + ) -> _models.LoggerContract: """Creates or Updates a logger. :param resource_group_name: The name of the resource group. @@ -533,22 +580,26 @@ def create_or_update( :param logger_id: Logger identifier. Must be unique in the API Management service instance. :type logger_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.LoggerContract + :type parameters: ~azure.mgmt.apimanagement.models.LoggerContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LoggerContract, or the result of cls(response) - :rtype: ~api_management_client.models.LoggerContract + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LoggerContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LoggerContract] _json = self._serialize.body(parameters, 'LoggerContract') @@ -557,15 +608,22 @@ def create_or_update( service_name=service_name, logger_id=logger_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -589,7 +647,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # type: ignore @distributed_trace @@ -599,9 +657,9 @@ def update( service_name: str, logger_id: str, if_match: str, - parameters: "_models.LoggerUpdateContract", + parameters: _models.LoggerUpdateContract, **kwargs: Any - ) -> "_models.LoggerContract": + ) -> _models.LoggerContract: """Updates an existing logger. :param resource_group_name: The name of the resource group. @@ -614,19 +672,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.LoggerUpdateContract + :type parameters: ~azure.mgmt.apimanagement.models.LoggerUpdateContract :keyword callable cls: A custom type or function that will be passed the direct response :return: LoggerContract, or the result of cls(response) - :rtype: ~api_management_client.models.LoggerContract + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LoggerContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LoggerContract] _json = self._serialize.body(parameters, 'LoggerUpdateContract') @@ -635,15 +697,22 @@ def update( service_name=service_name, logger_id=logger_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -661,11 +730,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -689,11 +758,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -701,13 +775,20 @@ def delete( service_name=service_name, logger_id=logger_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -718,5 +799,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_named_value_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_named_value_operations.py index 9392f40884fd..8b0747bf5a1d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_named_value_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_named_value_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -40,39 +40,41 @@ def build_list_by_service_request( is_key_vault_refresh_failed: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) if is_key_vault_refresh_failed is not None: - query_parameters['isKeyVaultRefreshFailed'] = _SERIALIZER.query("is_key_vault_refresh_failed", is_key_vault_refresh_failed, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['isKeyVaultRefreshFailed'] = _SERIALIZER.query("is_key_vault_refresh_failed", is_key_vault_refresh_failed, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -84,10 +86,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -95,21 +101,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -121,10 +125,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -132,21 +140,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -157,17 +163,20 @@ def build_create_or_update_request_initial( named_value_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.NamedValueCreateContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -175,25 +184,23 @@ def build_create_or_update_request_initial( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -207,16 +214,19 @@ def build_update_request_initial( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.NamedValueUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -224,24 +234,22 @@ def build_update_request_initial( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -257,10 +265,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -268,22 +280,20 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -295,10 +305,14 @@ def build_list_value_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/listValue') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/listValue") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -306,21 +320,19 @@ def build_list_value_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -332,10 +344,14 @@ def build_refresh_secret_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -343,45 +359,41 @@ def build_refresh_secret_request_initial( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class NamedValueOperations(object): - """NamedValueOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NamedValueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`named_value` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -393,7 +405,7 @@ def list_by_service( skip: Optional[int] = None, is_key_vault_refresh_failed: Optional[bool] = None, **kwargs: Any - ) -> Iterable["_models.NamedValueCollection"]: + ) -> Iterable[_models.NamedValueCollection]: """Lists a collection of named values defined within a service instance. :param resource_group_name: The name of the resource group. @@ -404,26 +416,31 @@ def list_by_service( functions |
|-------------|-------------|-------------|-------------|
| tags | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith, any, all |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
. + |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :param is_key_vault_refresh_failed: When set to true, the response contains only named value - entities which failed refresh. + entities which failed refresh. Default value is None. :type is_key_vault_refresh_failed: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either NamedValueCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.NamedValueCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.NamedValueCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NamedValueCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -431,14 +448,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, is_key_vault_refresh_failed=is_key_vault_refresh_failed, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -446,14 +466,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, is_key_vault_refresh_failed=is_key_vault_refresh_failed, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -467,7 +490,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -481,7 +508,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues"} # type: ignore @distributed_trace def get_entity_tag( @@ -504,11 +531,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -516,12 +548,19 @@ def get_entity_tag( service_name=service_name, named_value_id=named_value_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -537,7 +576,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore @distributed_trace @@ -547,7 +586,7 @@ def get( service_name: str, named_value_id: str, **kwargs: Any - ) -> "_models.NamedValueContract": + ) -> _models.NamedValueContract: """Gets the details of the named value specified by its identifier. :param resource_group_name: The name of the resource group. @@ -558,14 +597,19 @@ def get( :type named_value_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: NamedValueContract, or the result of cls(response) - :rtype: ~api_management_client.models.NamedValueContract + :rtype: ~azure.mgmt.apimanagement.models.NamedValueContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NamedValueContract] request = build_get_request( @@ -573,12 +617,19 @@ def get( service_name=service_name, named_value_id=named_value_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -596,7 +647,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore def _create_or_update_initial( @@ -604,17 +655,21 @@ def _create_or_update_initial( resource_group_name: str, service_name: str, named_value_id: str, - parameters: "_models.NamedValueCreateContract", + parameters: _models.NamedValueCreateContract, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.NamedValueContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.NamedValueContract"]] + ) -> Optional[_models.NamedValueContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.NamedValueContract]] _json = self._serialize.body(parameters, 'NamedValueCreateContract') @@ -623,15 +678,22 @@ def _create_or_update_initial( service_name=service_name, named_value_id=named_value_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -655,7 +717,7 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore @distributed_trace @@ -664,10 +726,10 @@ def begin_create_or_update( resource_group_name: str, service_name: str, named_value_id: str, - parameters: "_models.NamedValueCreateContract", + parameters: _models.NamedValueCreateContract, if_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.NamedValueContract"]: + ) -> LROPoller[_models.NamedValueContract]: """Creates or updates named value. :param resource_group_name: The name of the resource group. @@ -677,9 +739,9 @@ def begin_create_or_update( :param named_value_id: Identifier of the NamedValue. :type named_value_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.NamedValueCreateContract + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueCreateContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -691,26 +753,33 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either NamedValueContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.NamedValueContract] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueContract"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.NamedValueContract] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, named_value_id=named_value_id, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -726,8 +795,14 @@ def get_long_running_output(pipeline_response): 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() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -736,10 +811,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore def _update_initial( self, @@ -747,16 +821,20 @@ def _update_initial( service_name: str, named_value_id: str, if_match: str, - parameters: "_models.NamedValueUpdateParameters", + parameters: _models.NamedValueUpdateParameters, **kwargs: Any - ) -> Optional["_models.NamedValueContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.NamedValueContract"]] + ) -> Optional[_models.NamedValueContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.NamedValueContract]] _json = self._serialize.body(parameters, 'NamedValueUpdateParameters') @@ -765,15 +843,22 @@ def _update_initial( service_name=service_name, named_value_id=named_value_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -792,7 +877,7 @@ def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore @distributed_trace @@ -802,9 +887,9 @@ def begin_update( service_name: str, named_value_id: str, if_match: str, - parameters: "_models.NamedValueUpdateParameters", + parameters: _models.NamedValueUpdateParameters, **kwargs: Any - ) -> LROPoller["_models.NamedValueContract"]: + ) -> LROPoller[_models.NamedValueContract]: """Updates the specific named value. :param resource_group_name: The name of the resource group. @@ -817,7 +902,7 @@ def begin_update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.NamedValueUpdateParameters + :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 @@ -828,26 +913,33 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either NamedValueContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.NamedValueContract] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueContract"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.NamedValueContract] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, named_value_id=named_value_id, if_match=if_match, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -863,8 +955,14 @@ def get_long_running_output(pipeline_response): 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() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -873,13 +971,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -903,11 +1000,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -915,13 +1017,20 @@ def delete( service_name=service_name, named_value_id=named_value_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -932,7 +1041,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}"} # type: ignore @distributed_trace @@ -942,7 +1051,7 @@ def list_value( service_name: str, named_value_id: str, **kwargs: Any - ) -> "_models.NamedValueSecretContract": + ) -> _models.NamedValueSecretContract: """Gets the secret of the named value specified by its identifier. :param resource_group_name: The name of the resource group. @@ -953,14 +1062,19 @@ def list_value( :type named_value_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: NamedValueSecretContract, or the result of cls(response) - :rtype: ~api_management_client.models.NamedValueSecretContract + :rtype: ~azure.mgmt.apimanagement.models.NamedValueSecretContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueSecretContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NamedValueSecretContract] request = build_list_value_request( @@ -968,12 +1082,19 @@ def list_value( service_name=service_name, named_value_id=named_value_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_value.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -991,7 +1112,7 @@ def list_value( return deserialized - list_value.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/listValue'} # type: ignore + list_value.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/listValue"} # type: ignore def _refresh_secret_initial( @@ -1000,12 +1121,17 @@ def _refresh_secret_initial( service_name: str, named_value_id: str, **kwargs: Any - ) -> Optional["_models.NamedValueContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.NamedValueContract"]] + ) -> Optional[_models.NamedValueContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.NamedValueContract]] request = build_refresh_secret_request_initial( @@ -1013,12 +1139,19 @@ def _refresh_secret_initial( service_name=service_name, named_value_id=named_value_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._refresh_secret_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1037,7 +1170,7 @@ def _refresh_secret_initial( return deserialized - _refresh_secret_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret'} # type: ignore + _refresh_secret_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret"} # type: ignore @distributed_trace @@ -1047,7 +1180,7 @@ def begin_refresh_secret( service_name: str, named_value_id: str, **kwargs: Any - ) -> LROPoller["_models.NamedValueContract"]: + ) -> LROPoller[_models.NamedValueContract]: """Refresh the secret of the named value specified by its identifier. :param resource_group_name: The name of the resource group. @@ -1066,22 +1199,29 @@ def begin_refresh_secret( Retry-After header is present. :return: An instance of LROPoller that returns either NamedValueContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.NamedValueContract] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.NamedValueContract"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NamedValueContract] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._refresh_secret_initial( + raw_result = self._refresh_secret_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, named_value_id=named_value_id, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1097,8 +1237,14 @@ def get_long_running_output(pipeline_response): 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() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1107,7 +1253,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh_secret.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret'} # type: ignore + begin_refresh_secret.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_network_status_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_network_status_operations.py index e08388461e8d..e5bd31dde59e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_network_status_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_network_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,20 +6,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 typing import Any, Callable, Dict, List, Optional, TypeVar + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -31,31 +32,33 @@ def build_list_by_service_request( service_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -67,10 +70,14 @@ def build_list_by_location_request( location_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/locations/{locationName}/networkstatus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/locations/{locationName}/networkstatus") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), @@ -78,45 +85,41 @@ def build_list_by_location_request( "locationName": _SERIALIZER.url("location_name", location_name, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class NetworkStatusOperations(object): - """NetworkStatusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NetworkStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`network_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -124,7 +127,7 @@ def list_by_service( resource_group_name: str, service_name: str, **kwargs: Any - ) -> List["_models.NetworkStatusContractByLocation"]: + ) -> 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. @@ -135,26 +138,38 @@ def list_by_service( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: list of NetworkStatusContractByLocation, or the result of cls(response) - :rtype: list[~api_management_client.models.NetworkStatusContractByLocation] + :rtype: list[~azure.mgmt.apimanagement.models.NetworkStatusContractByLocation] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.NetworkStatusContractByLocation"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.NetworkStatusContractByLocation]] request = build_list_by_service_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,7 +184,7 @@ def list_by_service( return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus"} # type: ignore @distributed_trace @@ -179,7 +194,7 @@ def list_by_location( service_name: str, location_name: str, **kwargs: Any - ) -> "_models.NetworkStatusContract": + ) -> _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. @@ -193,14 +208,19 @@ def list_by_location( :type location_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: NetworkStatusContract, or the result of cls(response) - :rtype: ~api_management_client.models.NetworkStatusContract + :rtype: ~azure.mgmt.apimanagement.models.NetworkStatusContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkStatusContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkStatusContract] request = build_list_by_location_request( @@ -208,12 +228,19 @@ def list_by_location( resource_group_name=resource_group_name, service_name=service_name, location_name=location_name, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -228,5 +255,5 @@ def list_by_location( return deserialized - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/locations/{locationName}/networkstatus'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/locations/{locationName}/networkstatus"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_operations.py index eb180a16c320..745eefa68b1f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -35,35 +36,37 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -75,10 +78,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -86,21 +93,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -114,10 +119,14 @@ def build_create_or_update_request( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -125,47 +134,43 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class NotificationOperations(object): - """NotificationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NotificationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`notification` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -175,28 +180,33 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.NotificationCollection"]: + ) -> Iterable[_models.NotificationCollection]: """Lists a collection of properties defined within a 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 top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either NotificationCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.NotificationCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.NotificationCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NotificationCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NotificationCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -204,12 +214,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -217,12 +230,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -236,7 +252,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -250,7 +270,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications"} # type: ignore @distributed_trace def get( @@ -259,7 +279,7 @@ def get( service_name: str, notification_name: Union[str, "_models.NotificationName"], **kwargs: Any - ) -> "_models.NotificationContract": + ) -> _models.NotificationContract: """Gets the details of the Notification specified by its identifier. :param resource_group_name: The name of the resource group. @@ -267,17 +287,22 @@ def get( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :keyword callable cls: A custom type or function that will be passed the direct response :return: NotificationContract, or the result of cls(response) - :rtype: ~api_management_client.models.NotificationContract + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NotificationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NotificationContract] request = build_get_request( @@ -285,12 +310,19 @@ def get( service_name=service_name, notification_name=notification_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -305,7 +337,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}"} # type: ignore @distributed_trace @@ -316,7 +348,7 @@ def create_or_update( notification_name: Union[str, "_models.NotificationName"], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.NotificationContract": + ) -> _models.NotificationContract: """Create or Update API Management publisher notification. :param resource_group_name: The name of the resource group. @@ -324,20 +356,25 @@ def create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: NotificationContract, or the result of cls(response) - :rtype: ~api_management_client.models.NotificationContract + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NotificationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.NotificationContract] request = build_create_or_update_request( @@ -345,13 +382,20 @@ def create_or_update( service_name=service_name, notification_name=notification_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -366,5 +410,5 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_email_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_email_operations.py index 4e6a042c0b92..cf6d915c3ef7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_email_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_email_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,20 +6,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 typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -32,10 +33,14 @@ def build_list_by_notification_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -43,21 +48,19 @@ def build_list_by_notification_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -70,10 +73,14 @@ def build_check_entity_exists_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -82,21 +89,19 @@ def build_check_entity_exists_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -109,10 +114,14 @@ def build_create_or_update_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -121,21 +130,19 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -148,10 +155,14 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -160,45 +171,41 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class NotificationRecipientEmailOperations(object): - """NotificationRecipientEmailOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NotificationRecipientEmailOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`notification_recipient_email` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_notification( @@ -207,7 +214,7 @@ def list_by_notification( service_name: str, notification_name: Union[str, "_models.NotificationName"], **kwargs: Any - ) -> "_models.RecipientEmailCollection": + ) -> _models.RecipientEmailCollection: """Gets the list of the Notification Recipient Emails subscribed to a notification. :param resource_group_name: The name of the resource group. @@ -215,17 +222,22 @@ def list_by_notification( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :keyword callable cls: A custom type or function that will be passed the direct response :return: RecipientEmailCollection, or the result of cls(response) - :rtype: ~api_management_client.models.RecipientEmailCollection + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecipientEmailCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecipientEmailCollection] request = build_list_by_notification_request( @@ -233,12 +245,19 @@ def list_by_notification( service_name=service_name, notification_name=notification_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_notification.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -253,7 +272,7 @@ def list_by_notification( return deserialized - list_by_notification.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails'} # type: ignore + list_by_notification.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails"} # type: ignore @distributed_trace @@ -272,7 +291,7 @@ def check_entity_exists( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :param email: Email identifier. :type email: str :keyword callable cls: A custom type or function that will be passed the direct response @@ -280,11 +299,16 @@ def check_entity_exists( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_check_entity_exists_request( @@ -293,12 +317,19 @@ def check_entity_exists( notification_name=notification_name, email=email, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.check_entity_exists.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -310,7 +341,7 @@ def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} # type: ignore + check_entity_exists.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}"} # type: ignore @distributed_trace @@ -321,7 +352,7 @@ def create_or_update( notification_name: Union[str, "_models.NotificationName"], email: str, **kwargs: Any - ) -> "_models.RecipientEmailContract": + ) -> _models.RecipientEmailContract: """Adds the Email address to the list of Recipients for the Notification. :param resource_group_name: The name of the resource group. @@ -329,19 +360,24 @@ def create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :param email: Email identifier. :type email: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RecipientEmailContract, or the result of cls(response) - :rtype: ~api_management_client.models.RecipientEmailContract + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecipientEmailContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecipientEmailContract] request = build_create_or_update_request( @@ -350,12 +386,19 @@ def create_or_update( notification_name=notification_name, email=email, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -374,11 +417,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -393,7 +436,7 @@ def delete( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :param email: Email identifier. :type email: str :keyword callable cls: A custom type or function that will be passed the direct response @@ -401,11 +444,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -414,12 +462,19 @@ def delete( notification_name=notification_name, email=email, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -430,5 +485,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_user_operations.py index af00d3806ca9..e059e98de582 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_user_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_user_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,20 +6,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 typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -32,10 +33,14 @@ def build_list_by_notification_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -43,21 +48,19 @@ def build_list_by_notification_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -70,10 +73,14 @@ def build_check_entity_exists_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -82,21 +89,19 @@ def build_check_entity_exists_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -109,10 +114,14 @@ def build_create_or_update_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -121,21 +130,19 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -148,10 +155,14 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -160,45 +171,41 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class NotificationRecipientUserOperations(object): - """NotificationRecipientUserOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NotificationRecipientUserOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`notification_recipient_user` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_notification( @@ -207,7 +214,7 @@ def list_by_notification( service_name: str, notification_name: Union[str, "_models.NotificationName"], **kwargs: Any - ) -> "_models.RecipientUserCollection": + ) -> _models.RecipientUserCollection: """Gets the list of the Notification Recipient User subscribed to the notification. :param resource_group_name: The name of the resource group. @@ -215,17 +222,22 @@ def list_by_notification( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :keyword callable cls: A custom type or function that will be passed the direct response :return: RecipientUserCollection, or the result of cls(response) - :rtype: ~api_management_client.models.RecipientUserCollection + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecipientUserCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecipientUserCollection] request = build_list_by_notification_request( @@ -233,12 +245,19 @@ def list_by_notification( service_name=service_name, notification_name=notification_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_notification.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -253,7 +272,7 @@ def list_by_notification( return deserialized - list_by_notification.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers'} # type: ignore + list_by_notification.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers"} # type: ignore @distributed_trace @@ -272,7 +291,7 @@ def check_entity_exists( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str :keyword callable cls: A custom type or function that will be passed the direct response @@ -280,11 +299,16 @@ def check_entity_exists( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_check_entity_exists_request( @@ -293,12 +317,19 @@ def check_entity_exists( notification_name=notification_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.check_entity_exists.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204, 404]: @@ -310,7 +341,7 @@ def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} # type: ignore + check_entity_exists.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}"} # type: ignore @distributed_trace @@ -321,7 +352,7 @@ def create_or_update( notification_name: Union[str, "_models.NotificationName"], user_id: str, **kwargs: Any - ) -> "_models.RecipientUserContract": + ) -> _models.RecipientUserContract: """Adds the API Management User to the list of Recipients for the Notification. :param resource_group_name: The name of the resource group. @@ -329,19 +360,24 @@ def create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RecipientUserContract, or the result of cls(response) - :rtype: ~api_management_client.models.RecipientUserContract + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecipientUserContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecipientUserContract] request = build_create_or_update_request( @@ -350,12 +386,19 @@ def create_or_update( notification_name=notification_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -374,11 +417,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -393,7 +436,7 @@ def delete( :param service_name: The name of the API Management service. :type service_name: str :param notification_name: Notification Name Identifier. - :type notification_name: str or ~api_management_client.models.NotificationName + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str :keyword callable cls: A custom type or function that will be passed the direct response @@ -401,11 +444,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -414,12 +462,19 @@ def delete( notification_name=notification_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -430,5 +485,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_open_id_connect_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_open_id_connect_provider_operations.py index 18d7fc5d6291..db8289238f7c 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_open_id_connect_provider_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_open_id_connect_provider_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -79,10 +81,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -90,21 +96,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -116,10 +120,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -127,21 +135,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -152,17 +158,20 @@ def build_create_or_update_request( opid: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.OpenidConnectProviderContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -170,25 +179,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -202,16 +209,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.OpenidConnectProviderUpdateContract] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -219,24 +229,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -252,10 +260,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -263,22 +275,20 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -290,10 +300,14 @@ def build_list_secrets_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}/listSecrets') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}/listSecrets") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -301,45 +315,41 @@ def build_list_secrets_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class OpenIdConnectProviderOperations(object): - """OpenIdConnectProviderOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OpenIdConnectProviderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`open_id_connect_provider` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -350,7 +360,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.OpenIdConnectProviderCollection"]: + ) -> Iterable[_models.OpenIdConnectProviderCollection]: """Lists of all the OpenId Connect Providers. :param resource_group_name: The name of the resource group. @@ -361,24 +371,29 @@ def list_by_service( functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
. + |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OpenIdConnectProviderCollection or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~api_management_client.models.OpenIdConnectProviderCollection] + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.OpenIdConnectProviderCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenIdConnectProviderCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OpenIdConnectProviderCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -386,13 +401,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -400,13 +418,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -420,7 +441,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -434,7 +459,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders"} # type: ignore @distributed_trace def get_entity_tag( @@ -457,11 +482,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -469,12 +499,19 @@ def get_entity_tag( service_name=service_name, opid=opid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -490,7 +527,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # type: ignore @distributed_trace @@ -500,7 +537,7 @@ def get( service_name: str, opid: str, **kwargs: Any - ) -> "_models.OpenidConnectProviderContract": + ) -> _models.OpenidConnectProviderContract: """Gets specific OpenID Connect Provider without secrets. :param resource_group_name: The name of the resource group. @@ -511,14 +548,19 @@ def get( :type opid: str :keyword callable cls: A custom type or function that will be passed the direct response :return: OpenidConnectProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.OpenidConnectProviderContract + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenidConnectProviderContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OpenidConnectProviderContract] request = build_get_request( @@ -526,12 +568,19 @@ def get( service_name=service_name, opid=opid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -549,7 +598,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # type: ignore @distributed_trace @@ -558,10 +607,10 @@ def create_or_update( resource_group_name: str, service_name: str, opid: str, - parameters: "_models.OpenidConnectProviderContract", + parameters: _models.OpenidConnectProviderContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.OpenidConnectProviderContract": + ) -> _models.OpenidConnectProviderContract: """Creates or updates the OpenID Connect Provider. :param resource_group_name: The name of the resource group. @@ -571,22 +620,26 @@ def create_or_update( :param opid: Identifier of the OpenID Connect Provider. :type opid: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.OpenidConnectProviderContract + :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: OpenidConnectProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.OpenidConnectProviderContract + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenidConnectProviderContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OpenidConnectProviderContract] _json = self._serialize.body(parameters, 'OpenidConnectProviderContract') @@ -595,15 +648,22 @@ def create_or_update( service_name=service_name, opid=opid, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -627,7 +687,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # type: ignore @distributed_trace @@ -637,9 +697,9 @@ def update( service_name: str, opid: str, if_match: str, - parameters: "_models.OpenidConnectProviderUpdateContract", + parameters: _models.OpenidConnectProviderUpdateContract, **kwargs: Any - ) -> "_models.OpenidConnectProviderContract": + ) -> _models.OpenidConnectProviderContract: """Updates the specific OpenID Connect Provider. :param resource_group_name: The name of the resource group. @@ -652,19 +712,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.OpenidConnectProviderUpdateContract + :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderUpdateContract :keyword callable cls: A custom type or function that will be passed the direct response :return: OpenidConnectProviderContract, or the result of cls(response) - :rtype: ~api_management_client.models.OpenidConnectProviderContract + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OpenidConnectProviderContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OpenidConnectProviderContract] _json = self._serialize.body(parameters, 'OpenidConnectProviderUpdateContract') @@ -673,15 +737,22 @@ def update( service_name=service_name, opid=opid, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -699,11 +770,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -727,11 +798,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -739,13 +815,20 @@ def delete( service_name=service_name, opid=opid, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -756,7 +839,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}"} # type: ignore @distributed_trace @@ -766,7 +849,7 @@ def list_secrets( service_name: str, opid: str, **kwargs: Any - ) -> "_models.ClientSecretContract": + ) -> _models.ClientSecretContract: """Gets the client secret details of the OpenID Connect Provider. :param resource_group_name: The name of the resource group. @@ -777,14 +860,19 @@ def list_secrets( :type opid: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ClientSecretContract, or the result of cls(response) - :rtype: ~api_management_client.models.ClientSecretContract + :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClientSecretContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ClientSecretContract] request = build_list_secrets_request( @@ -792,12 +880,19 @@ def list_secrets( service_name=service_name, opid=opid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_secrets.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -815,5 +910,5 @@ def list_secrets( return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}/listSecrets'} # type: ignore + list_secrets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_operations.py index 009fc1d9d6c3..445685a65c2a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,10 +39,14 @@ def build_list_by_tags_request( include_not_tagged_operations: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operationsByTags') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operationsByTags") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -49,53 +54,49 @@ def build_list_by_tags_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) if include_not_tagged_operations is not None: - query_parameters['includeNotTaggedOperations'] = _SERIALIZER.query("include_not_tagged_operations", include_not_tagged_operations, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['includeNotTaggedOperations'] = _SERIALIZER.query("include_not_tagged_operations", include_not_tagged_operations, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class OperationOperations(object): - """OperationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OperationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`operation` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_tags( @@ -108,7 +109,7 @@ def list_by_tags( skip: Optional[int] = None, include_not_tagged_operations: Optional[bool] = None, **kwargs: Any - ) -> Iterable["_models.TagResourceCollection"]: + ) -> Iterable[_models.TagResourceCollection]: """Lists a collection of operations associated with tags. :param resource_group_name: The name of the resource group. @@ -126,25 +127,30 @@ def list_by_tags( |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| method | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| urlTemplate | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
. + startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param include_not_tagged_operations: Include not tagged Operations. + :param include_not_tagged_operations: Include not tagged Operations. Default value is None. :type include_not_tagged_operations: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TagResourceCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagResourceCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -153,14 +159,17 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, include_not_tagged_operations=include_not_tagged_operations, template_url=self.list_by_tags.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -169,14 +178,17 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, include_not_tagged_operations=include_not_tagged_operations, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -190,7 +202,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -204,4 +220,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operationsByTags'} # type: ignore + list_by_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operationsByTags"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_outbound_network_dependencies_endpoints_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_outbound_network_dependencies_endpoints_operations.py index 628cccd96107..03b9c75601fe 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_outbound_network_dependencies_endpoints_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_outbound_network_dependencies_endpoints_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,20 +6,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 typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -31,55 +32,55 @@ def build_list_by_service_request( service_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/outboundNetworkDependenciesEndpoints') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/outboundNetworkDependenciesEndpoints") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **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. +class OutboundNetworkDependenciesEndpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`outbound_network_dependencies_endpoints` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -87,7 +88,7 @@ def list_by_service( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.OutboundEnvironmentEndpointList": + ) -> _models.OutboundEnvironmentEndpointList: """Gets the network endpoints of all outbound dependencies of a ApiManagement service. :param resource_group_name: The name of the resource group. @@ -96,26 +97,38 @@ def list_by_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: ~api_management_client.models.OutboundEnvironmentEndpointList + :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OutboundEnvironmentEndpointList] request = build_list_by_service_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -130,5 +143,5 @@ def list_by_service( return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/outboundNetworkDependenciesEndpoints'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/outboundNetworkDependenciesEndpoints"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_patch.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_description_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_description_operations.py index 403985c5cb00..ea2d2bc42225 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_description_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_description_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,20 +6,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 typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -33,57 +34,57 @@ def build_list_by_service_request( scope: Optional[Union[str, "_models.PolicyScopeContract"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyDescriptions') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyDescriptions") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if scope is not None: - query_parameters['scope'] = _SERIALIZER.query("scope", scope, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['scope'] = _SERIALIZER.query("scope", scope, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PolicyDescriptionOperations(object): - """PolicyDescriptionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyDescriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`policy_description` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -92,38 +93,50 @@ def list_by_service( service_name: str, scope: Optional[Union[str, "_models.PolicyScopeContract"]] = None, **kwargs: Any - ) -> "_models.PolicyDescriptionCollection": + ) -> _models.PolicyDescriptionCollection: """Lists all policy descriptions. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param scope: Policy scope. - :type scope: str or ~api_management_client.models.PolicyScopeContract + :param scope: Policy scope. Default value is None. + :type scope: str or ~azure.mgmt.apimanagement.models.PolicyScopeContract :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyDescriptionCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyDescriptionCollection + :rtype: ~azure.mgmt.apimanagement.models.PolicyDescriptionCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyDescriptionCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyDescriptionCollection] request = build_list_by_service_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, scope=scope, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -138,5 +151,5 @@ def list_by_service( return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyDescriptions'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyDescriptions"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_fragment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_fragment_operations.py new file mode 100644 index 000000000000..d5674cfbb6db --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_fragment_operations.py @@ -0,0 +1,857 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast + +from msrest import Serializer + +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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + orderby: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyFragments") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if orderby is not None: + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + if top is not None: + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_entity_tag_request( + resource_group_name: str, + service_name: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyFragments/{id}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "id": _SERIALIZER.url("id", id, 'str', max_length=80, min_length=1, pattern=r'(^[\w]+$)|(^[\w][\w\-]+[\w]$)'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + service_name: str, + id: str, + subscription_id: str, + *, + format: Optional[Union[str, "_models.PolicyFragmentContentFormat"]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyFragments/{id}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "id": _SERIALIZER.url("id", id, 'str', max_length=80, min_length=1, pattern=r'(^[\w]+$)|(^[\w][\w\-]+[\w]$)'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if format is not None: + _params['format'] = _SERIALIZER.query("format", format, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + service_name: str, + id: str, + subscription_id: str, + *, + json: Optional[_models.PolicyFragmentContract] = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyFragments/{id}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "id": _SERIALIZER.url("id", id, 'str', max_length=80, min_length=1, pattern=r'(^[\w]+$)|(^[\w][\w\-]+[\w]$)'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if if_match is not None: + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + service_name: str, + id: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyFragments/{id}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "id": _SERIALIZER.url("id", id, 'str', max_length=80, min_length=1, pattern=r'(^[\w]+$)|(^[\w][\w\-]+[\w]$)'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_references_request( + resource_group_name: str, + service_name: str, + id: str, + subscription_id: str, + *, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyFragments/{id}/listReferences") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "id": _SERIALIZER.url("id", id, 'str', max_length=80, min_length=1, pattern=r'(^[\w]+$)|(^[\w][\w\-]+[\w]$)'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if top is not None: + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + if skip is not None: + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class PolicyFragmentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`policy_fragment` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + orderby: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> _models.PolicyFragmentCollection: + """Gets all policy fragments. + + :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, orderBy | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| value | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
. Default value is None. + :type filter: str + :param orderby: OData order by query option. Default value is None. + :type orderby: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyFragmentCollection, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyFragmentCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyFragmentCollection] + + + request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + orderby=orderby, + top=top, + skip=skip, + template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=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('PolicyFragmentCollection', 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}/policyFragments"} # type: ignore + + + @distributed_trace + def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + id: str, + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of a policy fragment. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param id: A resource identifier. + :type 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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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}/policyFragments/{id}"} # type: ignore + + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + id: str, + format: Optional[Union[str, "_models.PolicyFragmentContentFormat"]] = None, + **kwargs: Any + ) -> _models.PolicyFragmentContract: + """Gets a policy fragment. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param id: A resource identifier. + :type id: str + :param format: Policy fragment content format. Default value is None. + :type format: str or ~azure.mgmt.apimanagement.models.PolicyFragmentContentFormat + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyFragmentContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyFragmentContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyFragmentContract] + + + request = build_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + format=format, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('PolicyFragmentContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyFragments/{id}"} # type: ignore + + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + id: str, + parameters: _models.PolicyFragmentContract, + if_match: Optional[str] = None, + **kwargs: Any + ) -> Optional[_models.PolicyFragmentContract]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PolicyFragmentContract]] + + _json = self._serialize.body(parameters, 'PolicyFragmentContract') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 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('PolicyFragmentContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('PolicyFragmentContract', 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}/policyFragments/{id}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + id: str, + parameters: _models.PolicyFragmentContract, + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.PolicyFragmentContract]: + """Creates or updates a policy fragment. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param id: A resource identifier. + :type id: str + :param parameters: The policy fragment contents to apply. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyFragmentContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. Default value is None. + :type if_match: str + :keyword 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 PolicyFragmentContract or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PolicyFragmentContract] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyFragmentContract] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + 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('PolicyFragmentContract', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + 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}/policyFragments/{id}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + id: str, + if_match: str, + **kwargs: Any + ) -> None: + """Deletes a policy fragment. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param id: A resource identifier. + :type id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = 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}/policyFragments/{id}"} # type: ignore + + + @distributed_trace + def list_references( + self, + resource_group_name: str, + service_name: str, + id: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> _models.ResourceCollection: + """Lists policy resources that reference the policy fragment. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param id: A resource identifier. + :type id: str + :param top: Number of records to return. Default value is None. + :type top: int + :param skip: Number of records to skip. Default value is None. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceCollection, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ResourceCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceCollection] + + + request = build_list_references_request( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + top=top, + skip=skip, + template_url=self.list_references.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_references.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyFragments/{id}/listReferences"} # 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 10288c26e03d..ef480f8df5b7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_by_service_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -68,10 +70,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -79,21 +85,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -107,10 +111,14 @@ def build_get_request( format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -118,23 +126,21 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if format is not None: - query_parameters['format'] = _SERIALIZER.query("format", format, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['format'] = _SERIALIZER.query("format", format, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -145,17 +151,20 @@ def build_create_or_update_request( policy_id: Union[str, "_models.PolicyIdName"], subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.PolicyContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -163,25 +172,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -197,10 +204,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -208,46 +219,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PolicyOperations(object): - """PolicyOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`policy` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -255,7 +262,7 @@ def list_by_service( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.PolicyCollection": + ) -> _models.PolicyCollection: """Lists all the Global Policy definitions of the Api Management service. :param resource_group_name: The name of the resource group. @@ -264,26 +271,38 @@ def list_by_service( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyCollection + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyCollection] request = build_list_by_service_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -298,7 +317,7 @@ def list_by_service( return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies"} # type: ignore @distributed_trace @@ -317,17 +336,22 @@ def get_entity_tag( :param service_name: The name of the API Management service. :type service_name: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: bool, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -335,12 +359,19 @@ def get_entity_tag( service_name=service_name, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -356,7 +387,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}"} # type: ignore @distributed_trace @@ -367,7 +398,7 @@ def get( policy_id: Union[str, "_models.PolicyIdName"], format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Get the Global policy definition of the Api Management service. :param resource_group_name: The name of the resource group. @@ -375,19 +406,24 @@ def get( :param service_name: The name of the API Management service. :type service_name: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param format: Policy Export Format. - :type format: str or ~api_management_client.models.PolicyExportFormat + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. Default value is "xml". + :type format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyContract] request = build_get_request( @@ -395,13 +431,20 @@ def get( service_name=service_name, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, format=format, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -419,7 +462,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}"} # type: ignore @distributed_trace @@ -428,10 +471,10 @@ def create_or_update( resource_group_name: str, service_name: str, policy_id: Union[str, "_models.PolicyIdName"], - parameters: "_models.PolicyContract", + parameters: _models.PolicyContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Creates or updates the global policy configuration of the Api Management service. :param resource_group_name: The name of the resource group. @@ -439,24 +482,28 @@ def create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :param parameters: The policy contents to apply. - :type parameters: ~api_management_client.models.PolicyContract + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyContract] _json = self._serialize.body(parameters, 'PolicyContract') @@ -465,15 +512,22 @@ def create_or_update( service_name=service_name, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -497,11 +551,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -516,7 +570,7 @@ def delete( :param service_name: The name of the API Management service. :type service_name: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str @@ -525,11 +579,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -537,13 +596,20 @@ def delete( service_name=service_name, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -554,5 +620,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_config_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_config_operations.py new file mode 100644 index 000000000000..00cc35f2c6f0 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_config_operations.py @@ -0,0 +1,623 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer + +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.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_service_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_entity_tag_request( + subscription_id: str, + resource_group_name: str, + service_name: str, + portal_config_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "portalConfigId": _SERIALIZER.url("portal_config_id", portal_config_id, 'str', max_length=80, min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="HEAD", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + service_name: str, + portal_config_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "portalConfigId": _SERIALIZER.url("portal_config_id", portal_config_id, 'str', max_length=80, min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + service_name: str, + portal_config_id: str, + *, + if_match: str, + json: Optional[_models.PortalConfigContract] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "portalConfigId": _SERIALIZER.url("portal_config_id", portal_config_id, 'str', max_length=80, min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + service_name: str, + portal_config_id: str, + *, + if_match: str, + json: Optional[_models.PortalConfigContract] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + "portalConfigId": _SERIALIZER.url("portal_config_id", portal_config_id, 'str', max_length=80, min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class PortalConfigOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`portal_config` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + **kwargs: Any + ) -> _models.PortalConfigCollection: + """Lists the developer portal configurations. + + :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: PortalConfigCollection, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalConfigCollection] + + + request = build_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PortalConfigCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs"} # type: ignore + + + @distributed_trace + def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the developer portal configuration. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param portal_config_id: Portal configuration identifier. + :type portal_config_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 + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_get_entity_tag_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_name=service_name, + portal_config_id=portal_config_id, + api_version=api_version, + template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, 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}/portalconfigs/{portalConfigId}"} # type: ignore + + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + **kwargs: Any + ) -> _models.PortalConfigContract: + """Get the developer portal configuration. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param portal_config_id: Portal configuration identifier. + :type portal_config_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PortalConfigContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalConfigContract] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_name=service_name, + portal_config_id=portal_config_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('PortalConfigContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}"} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + if_match: str, + parameters: _models.PortalConfigContract, + **kwargs: Any + ) -> _models.PortalConfigContract: + """Update the developer portal configuration. + + :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 portal_config_id: Portal configuration identifier. + :type portal_config_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param parameters: Update the developer portal configuration. + :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PortalConfigContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalConfigContract] + + _json = self._serialize.body(parameters, 'PortalConfigContract') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_name=service_name, + portal_config_id=portal_config_id, + api_version=api_version, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PortalConfigContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + if_match: str, + parameters: _models.PortalConfigContract, + **kwargs: Any + ) -> _models.PortalConfigContract: + """Create or update the developer portal configuration. + + :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 portal_config_id: Portal configuration identifier. + :type portal_config_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param parameters: Update the developer portal configuration. + :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PortalConfigContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalConfigContract] + + _json = self._serialize.body(parameters, 'PortalConfigContract') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_name=service_name, + portal_config_id=portal_config_id, + api_version=api_version, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PortalConfigContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}"} # 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 0c7473630347..eceaed5d7cdf 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_revision_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_revision_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -39,37 +39,39 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -81,10 +83,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -92,21 +98,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -118,10 +122,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -129,21 +137,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -154,16 +160,19 @@ def build_create_or_update_request_initial( portal_revision_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.PortalRevisionContract] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -171,23 +180,21 @@ def build_create_or_update_request_initial( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -201,16 +208,19 @@ def build_update_request_initial( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.PortalRevisionContract] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -218,50 +228,46 @@ def build_update_request_initial( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class PortalRevisionOperations(object): - """PortalRevisionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PortalRevisionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`portal_revision` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -272,7 +278,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.PortalRevisionCollection"]: + ) -> Iterable[_models.PortalRevisionCollection]: """Lists developer portal's revisions. :param resource_group_name: The name of the resource group. @@ -290,23 +296,28 @@ def list_by_service( |name | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith| |description | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith| - |isCurrent | eq, ne | |. + |isCurrent | eq, ne | |. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PortalRevisionCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.PortalRevisionCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PortalRevisionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalRevisionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalRevisionCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -314,13 +325,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -328,13 +342,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -348,7 +365,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,7 +383,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions"} # type: ignore @distributed_trace def get_entity_tag( @@ -386,11 +407,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -398,12 +424,19 @@ def get_entity_tag( service_name=service_name, portal_revision_id=portal_revision_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -419,7 +452,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # type: ignore @distributed_trace @@ -429,7 +462,7 @@ def get( service_name: str, portal_revision_id: str, **kwargs: Any - ) -> "_models.PortalRevisionContract": + ) -> _models.PortalRevisionContract: """Gets the developer portal's revision specified by its identifier. :param resource_group_name: The name of the resource group. @@ -441,14 +474,19 @@ def get( :type portal_revision_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PortalRevisionContract, or the result of cls(response) - :rtype: ~api_management_client.models.PortalRevisionContract + :rtype: ~azure.mgmt.apimanagement.models.PortalRevisionContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalRevisionContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalRevisionContract] request = build_get_request( @@ -456,12 +494,19 @@ def get( service_name=service_name, portal_revision_id=portal_revision_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -479,7 +524,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # type: ignore def _create_or_update_initial( @@ -487,16 +532,20 @@ def _create_or_update_initial( resource_group_name: str, service_name: str, portal_revision_id: str, - parameters: "_models.PortalRevisionContract", + parameters: _models.PortalRevisionContract, **kwargs: Any - ) -> Optional["_models.PortalRevisionContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PortalRevisionContract"]] + ) -> Optional[_models.PortalRevisionContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PortalRevisionContract]] _json = self._serialize.body(parameters, 'PortalRevisionContract') @@ -505,14 +554,21 @@ def _create_or_update_initial( service_name=service_name, portal_revision_id=portal_revision_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201, 202]: @@ -531,7 +587,7 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # type: ignore @distributed_trace @@ -540,9 +596,9 @@ def begin_create_or_update( resource_group_name: str, service_name: str, portal_revision_id: str, - parameters: "_models.PortalRevisionContract", + parameters: _models.PortalRevisionContract, **kwargs: Any - ) -> LROPoller["_models.PortalRevisionContract"]: + ) -> LROPoller[_models.PortalRevisionContract]: """Creates a new developer portal's revision by running the portal's publishing. The ``isCurrent`` property indicates if the revision is publicly accessible. @@ -554,7 +610,7 @@ def begin_create_or_update( Management service instance. :type portal_revision_id: str :param parameters: - :type parameters: ~api_management_client.models.PortalRevisionContract + :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 @@ -565,25 +621,32 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either PortalRevisionContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.PortalRevisionContract] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalRevisionContract"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalRevisionContract] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, portal_revision_id=portal_revision_id, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -599,8 +662,14 @@ def get_long_running_output(pipeline_response): 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() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -609,10 +678,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # type: ignore def _update_initial( self, @@ -620,16 +688,20 @@ def _update_initial( service_name: str, portal_revision_id: str, if_match: str, - parameters: "_models.PortalRevisionContract", + parameters: _models.PortalRevisionContract, **kwargs: Any - ) -> Optional["_models.PortalRevisionContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PortalRevisionContract"]] + ) -> Optional[_models.PortalRevisionContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PortalRevisionContract]] _json = self._serialize.body(parameters, 'PortalRevisionContract') @@ -638,15 +710,22 @@ def _update_initial( service_name=service_name, portal_revision_id=portal_revision_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -665,7 +744,7 @@ def _update_initial( return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # type: ignore @distributed_trace @@ -675,9 +754,9 @@ def begin_update( service_name: str, portal_revision_id: str, if_match: str, - parameters: "_models.PortalRevisionContract", + parameters: _models.PortalRevisionContract, **kwargs: Any - ) -> LROPoller["_models.PortalRevisionContract"]: + ) -> LROPoller[_models.PortalRevisionContract]: """Updates the description of specified portal revision or makes it current. :param resource_group_name: The name of the resource group. @@ -691,7 +770,7 @@ def begin_update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: - :type parameters: ~api_management_client.models.PortalRevisionContract + :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 @@ -702,26 +781,33 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either PortalRevisionContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.PortalRevisionContract] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalRevisionContract"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalRevisionContract] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, portal_revision_id=portal_revision_id, if_match=if_match, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -737,8 +823,14 @@ def get_long_running_output(pipeline_response): 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() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -747,7 +839,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}'} # type: ignore + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_settings_operations.py index 8bb66776b1a3..61c00c3ae30e 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,20 +6,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 typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -31,55 +32,55 @@ def build_list_by_service_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PortalSettingsOperations(object): - """PortalSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PortalSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`portal_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -87,7 +88,7 @@ def list_by_service( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.PortalSettingsCollection": + ) -> _models.PortalSettingsCollection: """Lists a collection of portalsettings defined within a service instance.. :param resource_group_name: The name of the resource group. @@ -96,26 +97,38 @@ def list_by_service( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PortalSettingsCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSettingsCollection + :rtype: ~azure.mgmt.apimanagement.models.PortalSettingsCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSettingsCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalSettingsCollection] request = build_list_by_service_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -130,5 +143,5 @@ def list_by_service( return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_private_endpoint_connection_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_private_endpoint_connection_operations.py index 02b1d94345e4..b15a639939f8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_private_endpoint_connection_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_private_endpoint_connection_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -35,31 +35,33 @@ def build_list_by_service_request( service_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -71,10 +73,14 @@ def build_get_by_name_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -82,21 +88,19 @@ def build_get_by_name_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -107,16 +111,19 @@ def build_create_or_update_request_initial( private_endpoint_connection_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnectionRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -124,23 +131,21 @@ def build_create_or_update_request_initial( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -154,10 +159,14 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -165,21 +174,19 @@ def build_delete_request_initial( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -190,31 +197,33 @@ def build_list_private_link_resources_request( service_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -226,10 +235,14 @@ def build_get_private_link_resource_request( private_link_sub_resource_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources/{privateLinkSubResourceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources/{privateLinkSubResourceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), @@ -237,45 +250,41 @@ def build_get_private_link_resource_request( "privateLinkSubResourceName": _SERIALIZER.url("private_link_sub_resource_name", private_link_sub_resource_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **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. +class PrivateEndpointConnectionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`private_endpoint_connection` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -283,7 +292,7 @@ def list_by_service( resource_group_name: str, service_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: """Lists all private endpoint connections of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -294,14 +303,19 @@ def list_by_service( :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~api_management_client.models.PrivateEndpointConnectionListResult] + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -309,10 +323,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -320,10 +337,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, service_name=service_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -337,7 +357,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -351,7 +375,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections"} # type: ignore @distributed_trace def get_by_name( @@ -360,7 +384,7 @@ def get_by_name( service_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the details of the Private Endpoint Connection specified by its identifier. :param resource_group_name: The name of the resource group. @@ -371,14 +395,19 @@ def get_by_name( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection, or the result of cls(response) - :rtype: ~api_management_client.models.PrivateEndpointConnection + :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_by_name_request( @@ -386,12 +415,19 @@ def get_by_name( service_name=service_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_by_name.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -406,7 +442,7 @@ def get_by_name( return deserialized - get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get_by_name.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _create_or_update_initial( @@ -414,16 +450,20 @@ def _create_or_update_initial( resource_group_name: str, service_name: str, private_endpoint_connection_name: str, - private_endpoint_connection_request: "_models.PrivateEndpointConnectionRequest", + private_endpoint_connection_request: _models.PrivateEndpointConnectionRequest, **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] + ) -> Optional[_models.PrivateEndpointConnection]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] _json = self._serialize.body(private_endpoint_connection_request, 'PrivateEndpointConnectionRequest') @@ -432,17 +472,24 @@ def _create_or_update_initial( service_name=service_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -455,7 +502,7 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace @@ -464,9 +511,9 @@ def begin_create_or_update( resource_group_name: str, service_name: str, private_endpoint_connection_name: str, - private_endpoint_connection_request: "_models.PrivateEndpointConnectionRequest", + private_endpoint_connection_request: _models.PrivateEndpointConnectionRequest, **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Creates a new Private Endpoint Connection or updates an existing one. :param resource_group_name: The name of the resource group. @@ -477,7 +524,7 @@ def begin_create_or_update( :type private_endpoint_connection_name: str :param private_endpoint_connection_request: :type private_endpoint_connection_request: - ~api_management_client.models.PrivateEndpointConnectionRequest + ~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 @@ -488,39 +535,52 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.PrivateEndpointConnection] + :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"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection_request=private_endpoint_connection_request, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **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() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -529,23 +589,27 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -553,12 +617,19 @@ def _delete_initial( service_name=service_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -568,11 +639,11 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace - def begin_delete( + def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -599,19 +670,26 @@ def begin_delete( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -621,8 +699,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -631,10 +715,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def list_private_link_resources( @@ -642,8 +725,8 @@ def list_private_link_resources( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": - """Description for Gets the private link resources. + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -651,26 +734,38 @@ def list_private_link_resources( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkResourceListResult, or the result of cls(response) - :rtype: ~api_management_client.models.PrivateLinkResourceListResult + :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_list_private_link_resources_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, service_name=service_name, + api_version=api_version, template_url=self.list_private_link_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -685,7 +780,7 @@ def list_private_link_resources( return deserialized - list_private_link_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources'} # type: ignore + list_private_link_resources.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources"} # type: ignore @distributed_trace @@ -695,8 +790,8 @@ def get_private_link_resource( service_name: str, private_link_sub_resource_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResource": - """Description for Gets the private link resources. + ) -> _models.PrivateLinkResource: + """Gets the private link resources. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -706,14 +801,19 @@ def get_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: ~api_management_client.models.PrivateLinkResource + :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResource] request = build_get_private_link_resource_request( @@ -721,12 +821,19 @@ def get_private_link_resource( subscription_id=self._config.subscription_id, service_name=service_name, private_link_sub_resource_name=private_link_sub_resource_name, + api_version=api_version, template_url=self.get_private_link_resource.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -741,5 +848,5 @@ def get_private_link_resource( return deserialized - get_private_link_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources/{privateLinkSubResourceName}'} # type: ignore + get_private_link_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources/{privateLinkSubResourceName}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_operations.py index 11167ec108af..47ca49deef3d 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -37,10 +38,14 @@ def build_list_by_product_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -48,27 +53,25 @@ def build_list_by_product_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -81,10 +84,14 @@ def build_check_entity_exists_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -93,21 +100,19 @@ def build_check_entity_exists_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -120,10 +125,14 @@ def build_create_or_update_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -132,21 +141,19 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -159,10 +166,14 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -171,45 +182,41 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ProductApiOperations(object): - """ProductApiOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProductApiOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`product_api` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_product( @@ -221,7 +228,7 @@ def list_by_product( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ApiCollection"]: + ) -> Iterable[_models.ApiCollection]: """Lists a collection of the APIs associated with a product. :param resource_group_name: The name of the resource group. @@ -238,22 +245,27 @@ def list_by_product( |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| serviceUrl | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
. + startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApiCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ApiCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -262,13 +274,16 @@ def prepare_request(next_link=None): service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_product.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -277,13 +292,16 @@ def prepare_request(next_link=None): service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -297,7 +315,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -311,7 +333,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis'} # type: ignore + list_by_product.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis"} # type: ignore @distributed_trace def check_entity_exists( @@ -339,11 +361,16 @@ def check_entity_exists( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_check_entity_exists_request( @@ -352,12 +379,19 @@ def check_entity_exists( product_id=product_id, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.check_entity_exists.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -369,7 +403,7 @@ def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} # type: ignore + check_entity_exists.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}"} # type: ignore @distributed_trace @@ -380,7 +414,7 @@ def create_or_update( product_id: str, api_id: str, **kwargs: Any - ) -> "_models.ApiContract": + ) -> _models.ApiContract: """Adds an API to the specified product. :param resource_group_name: The name of the resource group. @@ -395,14 +429,19 @@ def create_or_update( :type api_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ApiContract, or the result of cls(response) - :rtype: ~api_management_client.models.ApiContract + :rtype: ~azure.mgmt.apimanagement.models.ApiContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApiContract] request = build_create_or_update_request( @@ -411,12 +450,19 @@ def create_or_update( product_id=product_id, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -435,11 +481,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -464,11 +510,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -477,12 +528,19 @@ def delete( product_id=product_id, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -493,5 +551,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_group_operations.py index 210babc16865..f4deff899163 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_group_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_group_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -37,10 +38,14 @@ def build_list_by_product_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -48,27 +53,25 @@ def build_list_by_product_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -81,10 +84,14 @@ def build_check_entity_exists_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -93,21 +100,19 @@ def build_check_entity_exists_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -120,10 +125,14 @@ def build_create_or_update_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -132,21 +141,19 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -159,10 +166,14 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -171,45 +182,41 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ProductGroupOperations(object): - """ProductGroupOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProductGroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`product_group` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_product( @@ -221,7 +228,7 @@ def list_by_product( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.GroupCollection"]: + ) -> Iterable[_models.GroupCollection]: """Lists the collection of developer groups associated with the specified product. :param resource_group_name: The name of the resource group. @@ -234,22 +241,27 @@ def list_by_product( :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt | |
| displayName | filter | eq, ne | |
| - description | filter | eq, ne | |
. + description | filter | eq, ne | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GroupCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.GroupCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GroupCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GroupCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -258,13 +270,16 @@ def prepare_request(next_link=None): service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_product.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -273,13 +288,16 @@ def prepare_request(next_link=None): service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -293,7 +311,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -307,7 +329,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups'} # type: ignore + list_by_product.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups"} # type: ignore @distributed_trace def check_entity_exists( @@ -335,11 +357,16 @@ def check_entity_exists( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_check_entity_exists_request( @@ -348,12 +375,19 @@ def check_entity_exists( product_id=product_id, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.check_entity_exists.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -365,7 +399,7 @@ def check_entity_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} # type: ignore + check_entity_exists.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}"} # type: ignore @distributed_trace @@ -376,7 +410,7 @@ def create_or_update( product_id: str, group_id: str, **kwargs: Any - ) -> "_models.GroupContract": + ) -> _models.GroupContract: """Adds the association between the specified developer group with the specified product. :param resource_group_name: The name of the resource group. @@ -391,14 +425,19 @@ def create_or_update( :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GroupContract, or the result of cls(response) - :rtype: ~api_management_client.models.GroupContract + :rtype: ~azure.mgmt.apimanagement.models.GroupContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GroupContract] request = build_create_or_update_request( @@ -407,12 +446,19 @@ def create_or_update( product_id=product_id, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -431,11 +477,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -460,11 +506,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -473,12 +524,19 @@ def delete( product_id=product_id, group_id=group_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -489,5 +547,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_operations.py index 1033fc00cb01..d14e6352ce14 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -39,41 +39,43 @@ def build_list_by_service_request( tags: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) if expand_groups is not None: - query_parameters['expandGroups'] = _SERIALIZER.query("expand_groups", expand_groups, 'bool') + _params['expandGroups'] = _SERIALIZER.query("expand_groups", expand_groups, 'bool') if tags is not None: - query_parameters['tags'] = _SERIALIZER.query("tags", tags, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['tags'] = _SERIALIZER.query("tags", tags, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -85,10 +87,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -96,21 +102,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -122,10 +126,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -133,21 +141,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -158,17 +164,20 @@ def build_create_or_update_request( product_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProductContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -176,25 +185,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -208,16 +215,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.ProductUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -225,24 +235,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -259,10 +267,14 @@ def build_delete_request( delete_subscriptions: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -270,24 +282,22 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if delete_subscriptions is not None: - query_parameters['deleteSubscriptions'] = _SERIALIZER.query("delete_subscriptions", delete_subscriptions, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['deleteSubscriptions'] = _SERIALIZER.query("delete_subscriptions", delete_subscriptions, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -303,63 +313,63 @@ def build_list_by_tags_request( include_not_tagged_products: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/productsByTags') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/productsByTags") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) if include_not_tagged_products is not None: - query_parameters['includeNotTaggedProducts'] = _SERIALIZER.query("include_not_tagged_products", include_not_tagged_products, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['includeNotTaggedProducts'] = _SERIALIZER.query("include_not_tagged_products", include_not_tagged_products, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ProductOperations(object): - """ProductOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProductOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`product` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -372,7 +382,7 @@ def list_by_service( expand_groups: Optional[bool] = None, tags: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ProductCollection"]: + ) -> Iterable[_models.ProductCollection]: """Lists a collection of products in the specified service instance. :param resource_group_name: The name of the resource group. @@ -385,27 +395,33 @@ def list_by_service( displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| terms | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| state | filter | eq | |
| groups | expand | | |
. + endswith |
| state | filter | eq | |
| groups | expand | | |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :param expand_groups: When set to true, the response contains an array of groups that have visibility to the product. The default is false. :type expand_groups: bool - :param tags: Products which are part of a specific tag. + :param tags: Products which are part of a specific tag. Default value is None. :type tags: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProductCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ProductCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ProductCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProductCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -413,15 +429,18 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, expand_groups=expand_groups, tags=tags, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -429,15 +448,18 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, expand_groups=expand_groups, tags=tags, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -451,7 +473,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -465,7 +491,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products"} # type: ignore @distributed_trace def get_entity_tag( @@ -489,11 +515,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -501,12 +532,19 @@ def get_entity_tag( service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -522,7 +560,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # type: ignore @distributed_trace @@ -532,7 +570,7 @@ def get( service_name: str, product_id: str, **kwargs: Any - ) -> "_models.ProductContract": + ) -> _models.ProductContract: """Gets the details of the product specified by its identifier. :param resource_group_name: The name of the resource group. @@ -544,14 +582,19 @@ def get( :type product_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ProductContract, or the result of cls(response) - :rtype: ~api_management_client.models.ProductContract + :rtype: ~azure.mgmt.apimanagement.models.ProductContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProductContract] request = build_get_request( @@ -559,12 +602,19 @@ def get( service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -582,7 +632,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # type: ignore @distributed_trace @@ -591,10 +641,10 @@ def create_or_update( resource_group_name: str, service_name: str, product_id: str, - parameters: "_models.ProductContract", + parameters: _models.ProductContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ProductContract": + ) -> _models.ProductContract: """Creates or Updates a product. :param resource_group_name: The name of the resource group. @@ -605,22 +655,26 @@ def create_or_update( instance. :type product_id: str :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.ProductContract + :type parameters: ~azure.mgmt.apimanagement.models.ProductContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ProductContract, or the result of cls(response) - :rtype: ~api_management_client.models.ProductContract + :rtype: ~azure.mgmt.apimanagement.models.ProductContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProductContract] _json = self._serialize.body(parameters, 'ProductContract') @@ -629,15 +683,22 @@ def create_or_update( service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -661,7 +722,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # type: ignore @distributed_trace @@ -671,9 +732,9 @@ def update( service_name: str, product_id: str, if_match: str, - parameters: "_models.ProductUpdateParameters", + parameters: _models.ProductUpdateParameters, **kwargs: Any - ) -> "_models.ProductContract": + ) -> _models.ProductContract: """Update existing product details. :param resource_group_name: The name of the resource group. @@ -687,19 +748,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.ProductUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.ProductUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: ProductContract, or the result of cls(response) - :rtype: ~api_management_client.models.ProductContract + :rtype: ~azure.mgmt.apimanagement.models.ProductContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProductContract] _json = self._serialize.body(parameters, 'ProductUpdateParameters') @@ -708,15 +773,22 @@ def update( service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -734,11 +806,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -760,17 +832,23 @@ def delete( response of the GET request or it should be * for unconditional update. :type if_match: str :param delete_subscriptions: Delete existing subscriptions associated with the product or not. + Default value is None. :type delete_subscriptions: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -778,14 +856,21 @@ def delete( service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, delete_subscriptions=delete_subscriptions, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -796,7 +881,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}"} # type: ignore @distributed_trace @@ -809,7 +894,7 @@ def list_by_tags( skip: Optional[int] = None, include_not_tagged_products: Optional[bool] = None, **kwargs: Any - ) -> Iterable["_models.TagResourceCollection"]: + ) -> Iterable[_models.TagResourceCollection]: """Lists a collection of products associated with tags. :param resource_group_name: The name of the resource group. @@ -823,24 +908,30 @@ def list_by_tags( |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| terms | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| state | filter | eq | substringof, contains, startswith, endswith |
. + Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param include_not_tagged_products: Include not tagged Products. + :param include_not_tagged_products: Include not tagged Products. Default value is None. :type include_not_tagged_products: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TagResourceCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagResourceCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -848,14 +939,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, include_not_tagged_products=include_not_tagged_products, template_url=self.list_by_tags.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -863,14 +957,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, include_not_tagged_products=include_not_tagged_products, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -884,7 +981,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -898,4 +999,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/productsByTags'} # type: ignore + list_by_tags.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/productsByTags"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_policy_operations.py index 2528cc49c4e7..69bfed81d846 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_policy_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_policy_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,10 +33,14 @@ def build_list_by_product_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -44,21 +48,19 @@ def build_list_by_product_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -71,10 +73,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -83,21 +89,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -112,10 +116,14 @@ def build_get_request( format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -124,23 +132,21 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if format is not None: - query_parameters['format'] = _SERIALIZER.query("format", format, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['format'] = _SERIALIZER.query("format", format, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -152,17 +158,20 @@ def build_create_or_update_request( policy_id: Union[str, "_models.PolicyIdName"], subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.PolicyContract] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -171,25 +180,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -206,10 +213,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -218,46 +229,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ProductPolicyOperations(object): - """ProductPolicyOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProductPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`product_policy` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_product( @@ -266,7 +273,7 @@ def list_by_product( service_name: str, product_id: str, **kwargs: Any - ) -> "_models.PolicyCollection": + ) -> _models.PolicyCollection: """Get the policy configuration at the Product level. :param resource_group_name: The name of the resource group. @@ -278,14 +285,19 @@ def list_by_product( :type product_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyCollection, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyCollection + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyCollection] request = build_list_by_product_request( @@ -293,12 +305,19 @@ def list_by_product( service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_product.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -313,7 +332,7 @@ def list_by_product( return deserialized - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies'} # type: ignore + list_by_product.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies"} # type: ignore @distributed_trace @@ -335,17 +354,22 @@ def get_entity_tag( instance. :type product_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: bool, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -354,12 +378,19 @@ def get_entity_tag( product_id=product_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -375,7 +406,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}"} # type: ignore @distributed_trace @@ -387,7 +418,7 @@ def get( policy_id: Union[str, "_models.PolicyIdName"], format: Optional[Union[str, "_models.PolicyExportFormat"]] = "xml", **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Get the policy configuration at the Product level. :param resource_group_name: The name of the resource group. @@ -398,19 +429,24 @@ def get( instance. :type product_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName - :param format: Policy Export Format. - :type format: str or ~api_management_client.models.PolicyExportFormat + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. Default value is "xml". + :type format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyContract] request = build_get_request( @@ -419,13 +455,20 @@ def get( product_id=product_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, format=format, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -443,7 +486,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}"} # type: ignore @distributed_trace @@ -453,10 +496,10 @@ def create_or_update( service_name: str, product_id: str, policy_id: Union[str, "_models.PolicyIdName"], - parameters: "_models.PolicyContract", + parameters: _models.PolicyContract, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PolicyContract": + ) -> _models.PolicyContract: """Creates or updates policy configuration for the Product. :param resource_group_name: The name of the resource group. @@ -467,24 +510,28 @@ def create_or_update( instance. :type product_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :param parameters: The policy contents to apply. - :type parameters: ~api_management_client.models.PolicyContract + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyContract, or the result of cls(response) - :rtype: ~api_management_client.models.PolicyContract + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PolicyContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PolicyContract] _json = self._serialize.body(parameters, 'PolicyContract') @@ -494,15 +541,22 @@ def create_or_update( product_id=product_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -526,11 +580,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -549,7 +603,7 @@ def delete( instance. :type product_id: str :param policy_id: The identifier of the Policy. - :type policy_id: str or ~api_management_client.models.PolicyIdName + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str @@ -558,11 +612,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -571,13 +630,20 @@ def delete( product_id=product_id, policy_id=policy_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -588,5 +654,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_subscriptions_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_subscriptions_operations.py index a8fb8cd3f6cb..6a6e2f4b5af7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_subscriptions_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_subscriptions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -37,10 +38,14 @@ def build_list_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/subscriptions') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/subscriptions") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -48,51 +53,47 @@ def build_list_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ProductSubscriptionsOperations(object): - """ProductSubscriptionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProductSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`product_subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -104,7 +105,7 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.SubscriptionCollection"]: + ) -> Iterable[_models.SubscriptionCollection]: """Lists the collection of subscriptions to the specified product. :param resource_group_name: The name of the resource group. @@ -124,23 +125,28 @@ def list( endswith |
| userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| productId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| state | filter | eq | |
| user | expand | | - |
. + |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SubscriptionCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.SubscriptionCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.SubscriptionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -149,13 +155,16 @@ def prepare_request(next_link=None): service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -164,13 +173,16 @@ def prepare_request(next_link=None): service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -184,7 +196,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -198,4 +214,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/subscriptions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/subscriptions"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_counter_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_counter_keys_operations.py index 4ac1e1a88bd6..f1b97429e769 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_counter_keys_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_counter_keys_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,10 +33,14 @@ def build_list_by_service_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -44,21 +48,19 @@ def build_list_by_service_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,16 +71,19 @@ def build_update_request( quota_counter_key: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.QuotaCounterValueUpdateContract] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -86,49 +91,45 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class QuotaByCounterKeysOperations(object): - """QuotaByCounterKeysOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QuotaByCounterKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`quota_by_counter_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -137,7 +138,7 @@ def list_by_service( service_name: str, quota_counter_key: str, **kwargs: Any - ) -> "_models.QuotaCounterCollection": + ) -> _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. @@ -152,14 +153,19 @@ def list_by_service( :type quota_counter_key: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QuotaCounterCollection, or the result of cls(response) - :rtype: ~api_management_client.models.QuotaCounterCollection + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaCounterCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QuotaCounterCollection] request = build_list_by_service_request( @@ -167,12 +173,19 @@ def list_by_service( service_name=service_name, quota_counter_key=quota_counter_key, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -187,7 +200,7 @@ def list_by_service( return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}"} # type: ignore @distributed_trace @@ -196,9 +209,9 @@ def update( resource_group_name: str, service_name: str, quota_counter_key: str, - parameters: "_models.QuotaCounterValueUpdateContract", + parameters: _models.QuotaCounterValueUpdateContract, **kwargs: Any - ) -> "_models.QuotaCounterCollection": + ) -> _models.QuotaCounterCollection: """Updates all the quota counter values specified with the existing quota counter key to a value in the specified service instance. This should be used for reset of the quota counter values. @@ -212,19 +225,23 @@ def update( as counter-key="@("b"+"a")" then it will be accessible by "ba" key. :type quota_counter_key: str :param parameters: The value of the quota counter to be applied to all quota counter periods. - :type parameters: ~api_management_client.models.QuotaCounterValueUpdateContract + :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract :keyword callable cls: A custom type or function that will be passed the direct response :return: QuotaCounterCollection, or the result of cls(response) - :rtype: ~api_management_client.models.QuotaCounterCollection + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaCounterCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.QuotaCounterCollection] _json = self._serialize.body(parameters, 'QuotaCounterValueUpdateContract') @@ -233,14 +250,21 @@ def update( service_name=service_name, quota_counter_key=quota_counter_key, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -255,5 +279,5 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_period_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_period_keys_operations.py index 00621e347ba2..45e0adacc851 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_period_keys_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_period_keys_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -34,10 +34,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -46,21 +50,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -72,16 +74,19 @@ def build_update_request( quota_period_key: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.QuotaCounterValueUpdateContract] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -90,49 +95,45 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class QuotaByPeriodKeysOperations(object): - """QuotaByPeriodKeysOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QuotaByPeriodKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`quota_by_period_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -142,7 +143,7 @@ def get( quota_counter_key: str, quota_period_key: str, **kwargs: Any - ) -> "_models.QuotaCounterContract": + ) -> _models.QuotaCounterContract: """Gets the value of the quota counter associated with the counter-key in the policy for the specific period in service instance. @@ -159,14 +160,19 @@ def get( :type quota_period_key: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QuotaCounterContract, or the result of cls(response) - :rtype: ~api_management_client.models.QuotaCounterContract + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaCounterContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QuotaCounterContract] request = build_get_request( @@ -175,12 +181,19 @@ def get( quota_counter_key=quota_counter_key, quota_period_key=quota_period_key, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -195,7 +208,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}"} # type: ignore @distributed_trace @@ -205,9 +218,9 @@ def update( service_name: str, quota_counter_key: str, quota_period_key: str, - parameters: "_models.QuotaCounterValueUpdateContract", + parameters: _models.QuotaCounterValueUpdateContract, **kwargs: Any - ) -> "_models.QuotaCounterContract": + ) -> _models.QuotaCounterContract: """Updates an existing quota counter value in the specified service instance. :param resource_group_name: The name of the resource group. @@ -222,19 +235,23 @@ def update( :param quota_period_key: Quota period key identifier. :type quota_period_key: str :param parameters: The value of the Quota counter to be applied on the specified period. - :type parameters: ~api_management_client.models.QuotaCounterValueUpdateContract + :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract :keyword callable cls: A custom type or function that will be passed the direct response :return: QuotaCounterContract, or the result of cls(response) - :rtype: ~api_management_client.models.QuotaCounterContract + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaCounterContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.QuotaCounterContract] _json = self._serialize.body(parameters, 'QuotaCounterValueUpdateContract') @@ -244,14 +261,21 @@ def update( quota_counter_key=quota_counter_key, quota_period_key=quota_period_key, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -266,5 +290,5 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_region_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_region_operations.py index f31d8b3a042d..35ad47b52ee9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_region_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_region_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -32,55 +33,55 @@ def build_list_by_service_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/regions') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/regions") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class RegionOperations(object): - """RegionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RegionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`region` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -88,7 +89,7 @@ def list_by_service( resource_group_name: str, service_name: str, **kwargs: Any - ) -> Iterable["_models.RegionListResult"]: + ) -> Iterable[_models.RegionListResult]: """Lists all azure regions in which the service exists. :param resource_group_name: The name of the resource group. @@ -97,14 +98,19 @@ 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.paging.ItemPaged[~api_management_client.models.RegionListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.RegionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RegionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -112,10 +118,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -123,10 +132,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -140,7 +152,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -154,4 +170,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/regions'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/regions"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_reports_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_reports_operations.py index 37cdf036be34..a59d6d82e1dc 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_reports_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_reports_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +7,9 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,11 +17,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,38 +39,40 @@ def build_list_by_api_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) if orderby is not None: - query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -85,38 +88,40 @@ def build_list_by_user_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) if orderby is not None: - query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -132,38 +137,40 @@ def build_list_by_operation_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) if orderby is not None: - query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -179,38 +186,40 @@ def build_list_by_product_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) if orderby is not None: - query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -225,36 +234,38 @@ def build_list_by_geo_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -270,38 +281,40 @@ def build_list_by_subscription_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) if orderby is not None: - query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -318,39 +331,41 @@ def build_list_by_time_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) if orderby is not None: - query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - query_parameters['interval'] = _SERIALIZER.query("interval", interval, 'duration') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['interval'] = _SERIALIZER.query("interval", interval, 'duration') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -365,60 +380,60 @@ def build_list_by_request_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ReportsOperations(object): - """ReportsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ReportsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`reports` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_api( @@ -430,7 +445,7 @@ def list_by_api( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ReportCollection"]: + ) -> Iterable[_models.ReportCollection]: """Lists report records by API. :param resource_group_name: The name of the resource group. @@ -439,22 +454,27 @@ def list_by_api( :type service_name: str :param filter: The filter to apply on the operation. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ReportCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -462,14 +482,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=self.list_by_api.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -477,14 +500,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -498,7 +524,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -512,7 +542,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi'} # type: ignore + list_by_api.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi"} # type: ignore @distributed_trace def list_by_user( @@ -524,7 +554,7 @@ def list_by_user( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ReportCollection"]: + ) -> Iterable[_models.ReportCollection]: """Lists report records by User. :param resource_group_name: The name of the resource group. @@ -545,22 +575,27 @@ def list_by_user(
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ReportCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -568,14 +603,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=self.list_by_user.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,14 +621,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -604,7 +645,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -618,7 +663,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_user.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser'} # type: ignore + list_by_user.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser"} # type: ignore @distributed_trace def list_by_operation( @@ -630,7 +675,7 @@ def list_by_operation( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ReportCollection"]: + ) -> Iterable[_models.ReportCollection]: """Lists report records by API Operations. :param resource_group_name: The name of the resource group. @@ -651,22 +696,27 @@ def list_by_operation(
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ReportCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -674,14 +724,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=self.list_by_operation.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -689,14 +742,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -710,7 +766,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -724,7 +784,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation'} # type: ignore + list_by_operation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation"} # type: ignore @distributed_trace def list_by_product( @@ -736,7 +796,7 @@ def list_by_product( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ReportCollection"]: + ) -> Iterable[_models.ReportCollection]: """Lists report records by Product. :param resource_group_name: The name of the resource group. @@ -756,22 +816,27 @@ def list_by_product(
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ReportCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -779,14 +844,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=self.list_by_product.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -794,14 +862,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -815,7 +886,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -829,7 +904,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct'} # type: ignore + list_by_product.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct"} # type: ignore @distributed_trace def list_by_geo( @@ -840,7 +915,7 @@ def list_by_geo( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ReportCollection"]: + ) -> Iterable[_models.ReportCollection]: """Lists report records by geography. :param resource_group_name: The name of the resource group. @@ -861,20 +936,25 @@ def list_by_geo( serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ReportCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -882,13 +962,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_geo.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -896,13 +979,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -916,7 +1002,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -930,7 +1020,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_geo.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo'} # type: ignore + list_by_geo.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo"} # type: ignore @distributed_trace def list_by_subscription( @@ -942,7 +1032,7 @@ def list_by_subscription( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ReportCollection"]: + ) -> Iterable[_models.ReportCollection]: """Lists report records by subscription. :param resource_group_name: The name of the resource group. @@ -962,22 +1052,27 @@ def list_by_subscription(
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ReportCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -985,14 +1080,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1000,14 +1098,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, orderby=orderby, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1021,7 +1122,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1035,7 +1140,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription"} # type: ignore @distributed_trace def list_by_time( @@ -1048,7 +1153,7 @@ def list_by_time( skip: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ReportCollection"]: + ) -> Iterable[_models.ReportCollection]: """Lists report records by Time. :param resource_group_name: The name of the resource group. @@ -1073,22 +1178,27 @@ def list_by_time( code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :type interval: ~datetime.timedelta - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param orderby: OData order by query option. + :param orderby: OData order by query option. Default value is None. :type orderby: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReportCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.ReportCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReportCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1096,15 +1206,18 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, interval=interval, top=top, skip=skip, orderby=orderby, template_url=self.list_by_time.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1112,15 +1225,18 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, interval=interval, top=top, skip=skip, orderby=orderby, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1134,7 +1250,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1148,7 +1268,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_time.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime'} # type: ignore + list_by_time.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime"} # type: ignore @distributed_trace def list_by_request( @@ -1159,7 +1279,7 @@ def list_by_request( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.RequestReportCollection"]: + ) -> Iterable[_models.RequestReportCollection]: """Lists report records by Request. :param resource_group_name: The name of the resource group. @@ -1172,21 +1292,26 @@ def list_by_request( |
| productId | filter | eq | |
| userId | filter | eq | |
| apiRegion | filter | eq | |
| subscriptionId | filter | eq | |
. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RequestReportCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.RequestReportCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.RequestReportCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RequestReportCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RequestReportCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1194,13 +1319,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_request.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1208,13 +1336,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1228,7 +1359,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1242,4 +1377,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_request.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest'} # type: ignore + list_by_request.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_in_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_in_settings_operations.py index 5bd986e52e0d..815b2f39e676 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_in_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_in_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -67,31 +69,33 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -102,40 +106,41 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.PortalSigninSettings] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -147,68 +152,67 @@ def build_create_or_update_request( service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.PortalSigninSettings] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class SignInSettingsOperations(object): - """SignInSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SignInSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`sign_in_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get_entity_tag( @@ -228,23 +232,35 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -260,7 +276,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin"} # type: ignore @distributed_trace @@ -269,7 +285,7 @@ def get( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.PortalSigninSettings": + ) -> _models.PortalSigninSettings: """Get Sign In Settings for the Portal. :param resource_group_name: The name of the resource group. @@ -278,26 +294,38 @@ def get( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PortalSigninSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSigninSettings + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSigninSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalSigninSettings] request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -315,16 +343,16 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin"} # type: ignore @distributed_trace - def update( + def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, if_match: str, - parameters: "_models.PortalSigninSettings", + parameters: _models.PortalSigninSettings, **kwargs: Any ) -> None: """Update Sign-In settings. @@ -337,19 +365,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update Sign-In settings. - :type parameters: ~api_management_client.models.PortalSigninSettings + :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(parameters, 'PortalSigninSettings') @@ -357,15 +389,22 @@ def update( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -376,7 +415,7 @@ def update( if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin"} # type: ignore @distributed_trace @@ -384,10 +423,10 @@ def create_or_update( self, resource_group_name: str, service_name: str, - parameters: "_models.PortalSigninSettings", + parameters: _models.PortalSigninSettings, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PortalSigninSettings": + ) -> _models.PortalSigninSettings: """Create or Update Sign-In settings. :param resource_group_name: The name of the resource group. @@ -395,22 +434,26 @@ def create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.PortalSigninSettings + :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PortalSigninSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSigninSettings + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSigninSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalSigninSettings] _json = self._serialize.body(parameters, 'PortalSigninSettings') @@ -418,15 +461,22 @@ def create_or_update( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -441,5 +491,5 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_up_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_up_settings_operations.py index f5a8cb49bfc3..420c57fcb512 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_up_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_up_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -67,31 +69,33 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -102,40 +106,41 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.PortalSignupSettings] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -147,68 +152,67 @@ def build_create_or_update_request( service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.PortalSignupSettings] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class SignUpSettingsOperations(object): - """SignUpSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SignUpSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`sign_up_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get_entity_tag( @@ -228,23 +232,35 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -260,7 +276,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup"} # type: ignore @distributed_trace @@ -269,7 +285,7 @@ def get( resource_group_name: str, service_name: str, **kwargs: Any - ) -> "_models.PortalSignupSettings": + ) -> _models.PortalSignupSettings: """Get Sign Up Settings for the Portal. :param resource_group_name: The name of the resource group. @@ -278,26 +294,38 @@ def get( :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PortalSignupSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSignupSettings + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSignupSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalSignupSettings] request = build_get_request( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -315,16 +343,16 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup"} # type: ignore @distributed_trace - def update( + def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, if_match: str, - parameters: "_models.PortalSignupSettings", + parameters: _models.PortalSignupSettings, **kwargs: Any ) -> None: """Update Sign-Up settings. @@ -337,19 +365,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update Sign-Up settings. - :type parameters: ~api_management_client.models.PortalSignupSettings + :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(parameters, 'PortalSignupSettings') @@ -357,15 +389,22 @@ def update( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -376,7 +415,7 @@ def update( if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup"} # type: ignore @distributed_trace @@ -384,10 +423,10 @@ def create_or_update( self, resource_group_name: str, service_name: str, - parameters: "_models.PortalSignupSettings", + parameters: _models.PortalSignupSettings, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.PortalSignupSettings": + ) -> _models.PortalSignupSettings: """Create or Update Sign-Up settings. :param resource_group_name: The name of the resource group. @@ -395,22 +434,26 @@ def create_or_update( :param service_name: The name of the API Management service. :type service_name: str :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.PortalSignupSettings + :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PortalSignupSettings, or the result of cls(response) - :rtype: ~api_management_client.models.PortalSignupSettings + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PortalSignupSettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PortalSignupSettings] _json = self._serialize.body(parameters, 'PortalSignupSettings') @@ -418,15 +461,22 @@ def create_or_update( resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -441,5 +491,5 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_subscription_operations.py index 6a8d273c3c0c..130f61398476 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_subscription_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_subscription_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -79,10 +81,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -90,21 +96,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -116,10 +120,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -127,21 +135,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -152,19 +158,22 @@ def build_create_or_update_request( sid: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.SubscriptionCreateParameters] = 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] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -172,29 +181,27 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if notify is not None: - query_parameters['notify'] = _SERIALIZER.query("notify", notify, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['notify'] = _SERIALIZER.query("notify", notify, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if app_type is not None: - query_parameters['appType'] = _SERIALIZER.query("app_type", app_type, 'str') + _params['appType'] = _SERIALIZER.query("app_type", app_type, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -208,18 +215,21 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.SubscriptionUpdateParameters] = 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] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -227,28 +237,26 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if notify is not None: - query_parameters['notify'] = _SERIALIZER.query("notify", notify, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['notify'] = _SERIALIZER.query("notify", notify, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if app_type is not None: - query_parameters['appType'] = _SERIALIZER.query("app_type", app_type, 'str') + _params['appType'] = _SERIALIZER.query("app_type", app_type, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -264,10 +272,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -275,22 +287,20 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -302,10 +312,14 @@ def build_regenerate_primary_key_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regeneratePrimaryKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regeneratePrimaryKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -313,21 +327,19 @@ def build_regenerate_primary_key_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -339,10 +351,14 @@ def build_regenerate_secondary_key_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regenerateSecondaryKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regenerateSecondaryKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -350,21 +366,19 @@ def build_regenerate_secondary_key_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -376,10 +390,14 @@ def build_list_secrets_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/listSecrets') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/listSecrets") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -387,45 +405,41 @@ def build_list_secrets_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SubscriptionOperations(object): - """SubscriptionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SubscriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`subscription` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -436,7 +450,7 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.SubscriptionCollection"]: + ) -> Iterable[_models.SubscriptionCollection]: """Lists all subscriptions of the API Management service instance. :param resource_group_name: The name of the resource group. @@ -453,23 +467,28 @@ def list( endswith |
| userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| productId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| state | filter | eq | |
| user | expand | | - |
. + |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SubscriptionCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.SubscriptionCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.SubscriptionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -477,13 +496,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -491,13 +513,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -511,7 +536,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -525,7 +554,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions"} # type: ignore @distributed_trace def get_entity_tag( @@ -550,11 +579,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -562,12 +596,19 @@ def get_entity_tag( service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -583,7 +624,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # type: ignore @distributed_trace @@ -593,7 +634,7 @@ def get( service_name: str, sid: str, **kwargs: Any - ) -> "_models.SubscriptionContract": + ) -> _models.SubscriptionContract: """Gets the specified Subscription entity. :param resource_group_name: The name of the resource group. @@ -605,14 +646,19 @@ def get( :type sid: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionContract + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionContract] request = build_get_request( @@ -620,12 +666,19 @@ def get( service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -643,7 +696,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # type: ignore @distributed_trace @@ -652,12 +705,12 @@ def create_or_update( resource_group_name: str, service_name: str, sid: str, - parameters: "_models.SubscriptionCreateParameters", + parameters: _models.SubscriptionCreateParameters, notify: Optional[bool] = None, if_match: Optional[str] = None, app_type: Optional[Union[str, "_models.AppType"]] = None, **kwargs: Any - ) -> "_models.SubscriptionContract": + ) -> _models.SubscriptionContract: """Creates or updates the subscription of specified user to the specified product. :param resource_group_name: The name of the resource group. @@ -668,31 +721,35 @@ def create_or_update( user and a product in API Management. :type sid: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.SubscriptionCreateParameters + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionCreateParameters :param notify: Notify change in Subscription State. * If false, do not send any email notification for change of state of subscription - * If true, send email notification of change of state of subscription. + * If true, send email notification of change of state of subscription. Default value is None. :type notify: bool :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :param app_type: Determines the type of application which send the create user request. Default is legacy publisher portal. - :type app_type: str or ~api_management_client.models.AppType + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionContract + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionContract] _json = self._serialize.body(parameters, 'SubscriptionCreateParameters') @@ -701,17 +758,24 @@ def create_or_update( service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, notify=notify, if_match=if_match, app_type=app_type, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -735,7 +799,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # type: ignore @distributed_trace @@ -745,11 +809,11 @@ def update( service_name: str, sid: str, if_match: str, - parameters: "_models.SubscriptionUpdateParameters", + parameters: _models.SubscriptionUpdateParameters, notify: Optional[bool] = None, app_type: Optional[Union[str, "_models.AppType"]] = None, **kwargs: Any - ) -> "_models.SubscriptionContract": + ) -> _models.SubscriptionContract: """Updates the details of a subscription specified by its identifier. :param resource_group_name: The name of the resource group. @@ -763,28 +827,32 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.SubscriptionUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionUpdateParameters :param notify: Notify change in Subscription State. * If false, do not send any email notification for change of state of subscription - * If true, send email notification of change of state of subscription. + * If true, send email notification of change of state of subscription. Default value is None. :type notify: bool :param app_type: Determines the type of application which send the create user request. Default is legacy publisher portal. - :type app_type: str or ~api_management_client.models.AppType + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionContract + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionContract] _json = self._serialize.body(parameters, 'SubscriptionUpdateParameters') @@ -793,17 +861,24 @@ def update( service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, notify=notify, app_type=app_type, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -821,11 +896,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -850,11 +925,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -862,13 +942,20 @@ def delete( service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -879,11 +966,11 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"} # type: ignore @distributed_trace - def regenerate_primary_key( + def regenerate_primary_key( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -904,11 +991,16 @@ def regenerate_primary_key( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_regenerate_primary_key_request( @@ -916,12 +1008,19 @@ def regenerate_primary_key( service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.regenerate_primary_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -932,11 +1031,11 @@ def regenerate_primary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_primary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regeneratePrimaryKey'} # type: ignore + regenerate_primary_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regeneratePrimaryKey"} # type: ignore @distributed_trace - def regenerate_secondary_key( + def regenerate_secondary_key( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -957,11 +1056,16 @@ def regenerate_secondary_key( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_regenerate_secondary_key_request( @@ -969,12 +1073,19 @@ def regenerate_secondary_key( service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.regenerate_secondary_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -985,7 +1096,7 @@ def regenerate_secondary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regenerateSecondaryKey'} # type: ignore + regenerate_secondary_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regenerateSecondaryKey"} # type: ignore @distributed_trace @@ -995,7 +1106,7 @@ def list_secrets( service_name: str, sid: str, **kwargs: Any - ) -> "_models.SubscriptionKeysContract": + ) -> _models.SubscriptionKeysContract: """Gets the specified Subscription keys. :param resource_group_name: The name of the resource group. @@ -1007,14 +1118,19 @@ def list_secrets( :type sid: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionKeysContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionKeysContract + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionKeysContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionKeysContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionKeysContract] request = build_list_secrets_request( @@ -1022,12 +1138,19 @@ def list_secrets( service_name=service_name, sid=sid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_secrets.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1045,5 +1168,5 @@ def list_secrets( return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/listSecrets'} # type: ignore + list_secrets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_operations.py index 963a0651f991..e22cc5ca0862 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -39,10 +39,14 @@ def build_list_by_operation_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -51,27 +55,25 @@ def build_list_by_operation_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -85,10 +87,14 @@ def build_get_entity_state_by_operation_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -98,21 +104,19 @@ def build_get_entity_state_by_operation_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -126,10 +130,14 @@ def build_get_by_operation_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -139,21 +147,19 @@ def build_get_by_operation_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -167,10 +173,14 @@ def build_assign_to_operation_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -180,21 +190,19 @@ def build_assign_to_operation_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -208,10 +216,14 @@ def build_detach_from_operation_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -221,21 +233,19 @@ def build_detach_from_operation_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -251,10 +261,14 @@ def build_list_by_api_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -262,27 +276,25 @@ def build_list_by_api_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -295,10 +307,14 @@ def build_get_entity_state_by_api_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -307,21 +323,19 @@ def build_get_entity_state_by_api_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -334,10 +348,14 @@ def build_get_by_api_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -346,21 +364,19 @@ def build_get_by_api_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -373,10 +389,14 @@ def build_assign_to_api_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -385,21 +405,19 @@ def build_assign_to_api_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -412,10 +430,14 @@ def build_detach_from_api_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -424,21 +446,19 @@ def build_detach_from_api_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -454,10 +474,14 @@ def build_list_by_product_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -465,27 +489,25 @@ def build_list_by_product_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -498,10 +520,14 @@ def build_get_entity_state_by_product_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -510,21 +536,19 @@ def build_get_entity_state_by_product_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -537,10 +561,14 @@ def build_get_by_product_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -549,21 +577,19 @@ def build_get_by_product_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -576,10 +602,14 @@ def build_assign_to_product_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -588,21 +618,19 @@ def build_assign_to_product_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -615,10 +643,14 @@ def build_detach_from_product_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -627,21 +659,19 @@ def build_detach_from_product_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -657,39 +687,41 @@ def build_list_by_service_request( scope: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) if scope is not None: - query_parameters['scope'] = _SERIALIZER.query("scope", scope, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['scope'] = _SERIALIZER.query("scope", scope, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -701,10 +733,14 @@ def build_get_entity_state_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -712,21 +748,19 @@ def build_get_entity_state_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -738,10 +772,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -749,21 +787,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -774,17 +810,20 @@ def build_create_or_update_request( tag_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.TagCreateUpdateParameters] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -792,25 +831,23 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -824,16 +861,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.TagCreateUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -841,24 +881,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -874,10 +912,14 @@ def build_delete_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -885,46 +927,42 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TagOperations(object): - """TagOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TagOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`tag` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_operation( @@ -937,7 +975,7 @@ def list_by_operation( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.TagCollection"]: + ) -> Iterable[_models.TagCollection]: """Lists all Tags associated with the Operation. :param resource_group_name: The name of the resource group. @@ -953,22 +991,28 @@ def list_by_operation( :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TagCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -978,13 +1022,16 @@ def prepare_request(next_link=None): api_id=api_id, operation_id=operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_operation.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -994,13 +1041,16 @@ def prepare_request(next_link=None): api_id=api_id, operation_id=operation_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1014,7 +1064,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1028,7 +1082,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags'} # type: ignore + list_by_operation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags"} # type: ignore @distributed_trace def get_entity_state_by_operation( @@ -1059,11 +1113,16 @@ def get_entity_state_by_operation( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_state_by_operation_request( @@ -1073,12 +1132,19 @@ def get_entity_state_by_operation( operation_id=operation_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_state_by_operation.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1094,7 +1160,7 @@ def get_entity_state_by_operation( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_state_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore + get_entity_state_by_operation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}"} # type: ignore @distributed_trace @@ -1106,7 +1172,7 @@ def get_by_operation( operation_id: str, tag_id: str, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Get tag associated with the Operation. :param resource_group_name: The name of the resource group. @@ -1123,14 +1189,19 @@ def get_by_operation( :type tag_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract + :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagContract] request = build_get_by_operation_request( @@ -1140,12 +1211,19 @@ def get_by_operation( operation_id=operation_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_by_operation.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1163,7 +1241,7 @@ def get_by_operation( return deserialized - get_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore + get_by_operation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}"} # type: ignore @distributed_trace @@ -1175,7 +1253,7 @@ def assign_to_operation( operation_id: str, tag_id: str, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Assign tag to the Operation. :param resource_group_name: The name of the resource group. @@ -1192,14 +1270,19 @@ def assign_to_operation( :type tag_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract + :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagContract] request = build_assign_to_operation_request( @@ -1209,12 +1292,19 @@ def assign_to_operation( operation_id=operation_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.assign_to_operation.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1233,11 +1323,11 @@ def assign_to_operation( return deserialized - assign_to_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore + assign_to_operation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}"} # type: ignore @distributed_trace - def detach_from_operation( + def detach_from_operation( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -1265,11 +1355,16 @@ def detach_from_operation( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_detach_from_operation_request( @@ -1279,12 +1374,19 @@ def detach_from_operation( operation_id=operation_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.detach_from_operation.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1295,7 +1397,7 @@ def detach_from_operation( if cls: return cls(pipeline_response, None, {}) - detach_from_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore + detach_from_operation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}"} # type: ignore @distributed_trace @@ -1308,7 +1410,7 @@ def list_by_api( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.TagCollection"]: + ) -> Iterable[_models.TagCollection]: """Lists all Tags associated with the API. :param resource_group_name: The name of the resource group. @@ -1321,22 +1423,28 @@ def list_by_api( :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TagCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1345,13 +1453,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_api.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1360,13 +1471,16 @@ def prepare_request(next_link=None): service_name=service_name, api_id=api_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1380,7 +1494,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1394,7 +1512,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags'} # type: ignore + list_by_api.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags"} # type: ignore @distributed_trace def get_entity_state_by_api( @@ -1421,11 +1539,16 @@ def get_entity_state_by_api( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_state_by_api_request( @@ -1434,12 +1557,19 @@ def get_entity_state_by_api( api_id=api_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_state_by_api.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1455,7 +1585,7 @@ def get_entity_state_by_api( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_state_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore + get_entity_state_by_api.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}"} # type: ignore @distributed_trace @@ -1466,7 +1596,7 @@ def get_by_api( api_id: str, tag_id: str, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Get tag associated with the API. :param resource_group_name: The name of the resource group. @@ -1480,14 +1610,19 @@ def get_by_api( :type tag_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract + :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagContract] request = build_get_by_api_request( @@ -1496,12 +1631,19 @@ def get_by_api( api_id=api_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_by_api.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1519,7 +1661,7 @@ def get_by_api( return deserialized - get_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore + get_by_api.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}"} # type: ignore @distributed_trace @@ -1530,7 +1672,7 @@ def assign_to_api( api_id: str, tag_id: str, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Assign tag to the Api. :param resource_group_name: The name of the resource group. @@ -1544,14 +1686,19 @@ def assign_to_api( :type tag_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract + :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagContract] request = build_assign_to_api_request( @@ -1560,12 +1707,19 @@ def assign_to_api( api_id=api_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.assign_to_api.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1589,11 +1743,11 @@ def assign_to_api( return deserialized - assign_to_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore + assign_to_api.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}"} # type: ignore @distributed_trace - def detach_from_api( + def detach_from_api( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -1617,11 +1771,16 @@ def detach_from_api( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_detach_from_api_request( @@ -1630,12 +1789,19 @@ def detach_from_api( api_id=api_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.detach_from_api.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1646,7 +1812,7 @@ def detach_from_api( if cls: return cls(pipeline_response, None, {}) - detach_from_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore + detach_from_api.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}"} # type: ignore @distributed_trace @@ -1659,7 +1825,7 @@ def list_by_product( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.TagCollection"]: + ) -> Iterable[_models.TagCollection]: """Lists all Tags associated with the Product. :param resource_group_name: The name of the resource group. @@ -1672,22 +1838,28 @@ def list_by_product( :param filter: | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TagCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1696,13 +1868,16 @@ def prepare_request(next_link=None): service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_product.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1711,13 +1886,16 @@ def prepare_request(next_link=None): service_name=service_name, product_id=product_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1731,7 +1909,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1745,7 +1927,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags'} # type: ignore + list_by_product.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags"} # type: ignore @distributed_trace def get_entity_state_by_product( @@ -1772,11 +1954,16 @@ def get_entity_state_by_product( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_state_by_product_request( @@ -1785,12 +1972,19 @@ def get_entity_state_by_product( product_id=product_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_state_by_product.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1806,7 +2000,7 @@ def get_entity_state_by_product( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_state_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore + get_entity_state_by_product.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}"} # type: ignore @distributed_trace @@ -1817,7 +2011,7 @@ def get_by_product( product_id: str, tag_id: str, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Get tag associated with the Product. :param resource_group_name: The name of the resource group. @@ -1831,14 +2025,19 @@ def get_by_product( :type tag_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract + :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagContract] request = build_get_by_product_request( @@ -1847,12 +2046,19 @@ def get_by_product( product_id=product_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_by_product.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1870,7 +2076,7 @@ def get_by_product( return deserialized - get_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore + get_by_product.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}"} # type: ignore @distributed_trace @@ -1881,7 +2087,7 @@ def assign_to_product( product_id: str, tag_id: str, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Assign tag to the Product. :param resource_group_name: The name of the resource group. @@ -1895,14 +2101,19 @@ def assign_to_product( :type tag_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract + :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagContract] request = build_assign_to_product_request( @@ -1911,12 +2122,19 @@ def assign_to_product( product_id=product_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.assign_to_product.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -1935,11 +2153,11 @@ def assign_to_product( return deserialized - assign_to_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore + assign_to_product.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}"} # type: ignore @distributed_trace - def detach_from_product( + def detach_from_product( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -1963,11 +2181,16 @@ def detach_from_product( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_detach_from_product_request( @@ -1976,12 +2199,19 @@ def detach_from_product( product_id=product_id, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.detach_from_product.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1992,7 +2222,7 @@ def detach_from_product( if cls: return cls(pipeline_response, None, {}) - detach_from_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore + detach_from_product.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}"} # type: ignore @distributed_trace @@ -2005,7 +2235,7 @@ def list_by_service( skip: Optional[int] = None, scope: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.TagCollection"]: + ) -> Iterable[_models.TagCollection]: """Lists a collection of tags defined within a service instance. :param resource_group_name: The name of the resource group. @@ -2016,24 +2246,29 @@ def list_by_service( functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
. + |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param scope: Scope like 'apis', 'products' or 'apis/{apiId}. + :param scope: Scope like 'apis', 'products' or 'apis/{apiId}. Default value is None. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TagCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2041,14 +2276,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, scope=scope, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2056,14 +2294,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, scope=scope, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2077,7 +2318,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2091,7 +2336,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags"} # type: ignore @distributed_trace def get_entity_state( @@ -2114,11 +2359,16 @@ def get_entity_state( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_state_request( @@ -2126,12 +2376,19 @@ def get_entity_state( service_name=service_name, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_state.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2147,7 +2404,7 @@ def get_entity_state( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_state.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore + get_entity_state.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # type: ignore @distributed_trace @@ -2157,7 +2414,7 @@ def get( service_name: str, tag_id: str, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Gets the details of the tag specified by its identifier. :param resource_group_name: The name of the resource group. @@ -2168,14 +2425,19 @@ def get( :type tag_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract + :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagContract] request = build_get_request( @@ -2183,12 +2445,19 @@ def get( service_name=service_name, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2206,7 +2475,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # type: ignore @distributed_trace @@ -2215,10 +2484,10 @@ def create_or_update( resource_group_name: str, service_name: str, tag_id: str, - parameters: "_models.TagCreateUpdateParameters", + parameters: _models.TagCreateUpdateParameters, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Creates a tag. :param resource_group_name: The name of the resource group. @@ -2228,22 +2497,26 @@ def create_or_update( :param tag_id: Tag identifier. Must be unique in the current API Management service instance. :type tag_id: str :param parameters: Create parameters. - :type parameters: ~api_management_client.models.TagCreateUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract + :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagContract] _json = self._serialize.body(parameters, 'TagCreateUpdateParameters') @@ -2252,15 +2525,22 @@ def create_or_update( service_name=service_name, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -2284,7 +2564,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # type: ignore @distributed_trace @@ -2294,9 +2574,9 @@ def update( service_name: str, tag_id: str, if_match: str, - parameters: "_models.TagCreateUpdateParameters", + parameters: _models.TagCreateUpdateParameters, **kwargs: Any - ) -> "_models.TagContract": + ) -> _models.TagContract: """Updates the details of the tag specified by its identifier. :param resource_group_name: The name of the resource group. @@ -2309,19 +2589,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.TagCreateUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: TagContract, or the result of cls(response) - :rtype: ~api_management_client.models.TagContract + :rtype: ~azure.mgmt.apimanagement.models.TagContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagContract] _json = self._serialize.body(parameters, 'TagCreateUpdateParameters') @@ -2330,15 +2614,22 @@ def update( service_name=service_name, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2356,11 +2647,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -2384,11 +2675,16 @@ def delete( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -2396,13 +2692,20 @@ def delete( service_name=service_name, tag_id=tag_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2413,5 +2716,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_resource_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_resource_operations.py index 2d7cae70b46c..e63bd9539d8a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_resource_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -36,61 +37,61 @@ def build_list_by_service_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tagResources') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tagResources") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TagResourceOperations(object): - """TagResourceOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TagResourceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`tag_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -101,7 +102,7 @@ def list_by_service( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.TagResourceCollection"]: + ) -> Iterable[_models.TagResourceCollection]: """Lists a collection of resources associated with tags. :param resource_group_name: The name of the resource group. @@ -122,23 +123,28 @@ def list_by_service( contains, startswith, endswith |
| urlTemplate | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| terms | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| state | filter | eq | |
| isCurrent - | filter | eq | |
. + | filter | eq | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TagResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TagResourceCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagResourceCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TagResourceCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -146,13 +152,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -160,13 +169,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -180,7 +192,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -194,4 +210,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tagResources'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tagResources"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_git_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_git_operations.py index b9ffd2f72bca..cf94679b2317 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_git_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_git_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,20 +6,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 typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -32,10 +33,14 @@ def build_regenerate_primary_key_request( access_name: Union[str, "_models.AccessIdName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regeneratePrimaryKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regeneratePrimaryKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -43,21 +48,19 @@ def build_regenerate_primary_key_request( "accessName": _SERIALIZER.url("access_name", access_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +72,14 @@ def build_regenerate_secondary_key_request( access_name: Union[str, "_models.AccessIdName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regenerateSecondaryKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regenerateSecondaryKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -80,48 +87,44 @@ def build_regenerate_secondary_key_request( "accessName": _SERIALIZER.url("access_name", access_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TenantAccessGitOperations(object): - """TenantAccessGitOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantAccessGitOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`tenant_access_git` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace - def regenerate_primary_key( + def regenerate_primary_key( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -135,17 +138,22 @@ def regenerate_primary_key( :param service_name: The name of the API Management service. :type service_name: str :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_regenerate_primary_key_request( @@ -153,12 +161,19 @@ def regenerate_primary_key( service_name=service_name, subscription_id=self._config.subscription_id, access_name=access_name, + api_version=api_version, template_url=self.regenerate_primary_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -169,11 +184,11 @@ def regenerate_primary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_primary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regeneratePrimaryKey'} # type: ignore + regenerate_primary_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regeneratePrimaryKey"} # type: ignore @distributed_trace - def regenerate_secondary_key( + def regenerate_secondary_key( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -187,17 +202,22 @@ def regenerate_secondary_key( :param service_name: The name of the API Management service. :type service_name: str :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_regenerate_secondary_key_request( @@ -205,12 +225,19 @@ def regenerate_secondary_key( service_name=service_name, subscription_id=self._config.subscription_id, access_name=access_name, + api_version=api_version, template_url=self.regenerate_secondary_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -221,5 +248,5 @@ def regenerate_secondary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regenerateSecondaryKey'} # type: ignore + regenerate_secondary_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regenerateSecondaryKey"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_operations.py index 67212b4c8113..e0a240c925aa 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -35,33 +35,35 @@ def build_list_by_service_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -73,10 +75,14 @@ def build_get_entity_tag_request( access_name: Union[str, "_models.AccessIdName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -84,21 +90,19 @@ def build_get_entity_tag_request( "accessName": _SERIALIZER.url("access_name", access_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -110,10 +114,14 @@ def build_get_request( access_name: Union[str, "_models.AccessIdName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -121,21 +129,19 @@ def build_get_request( "accessName": _SERIALIZER.url("access_name", access_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -147,16 +153,19 @@ def build_create_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.AccessInformationCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -164,24 +173,22 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -195,16 +202,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.AccessInformationUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -212,24 +222,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -243,10 +251,14 @@ def build_regenerate_primary_key_request( access_name: Union[str, "_models.AccessIdName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regeneratePrimaryKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regeneratePrimaryKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -254,21 +266,19 @@ def build_regenerate_primary_key_request( "accessName": _SERIALIZER.url("access_name", access_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -280,10 +290,14 @@ def build_regenerate_secondary_key_request( access_name: Union[str, "_models.AccessIdName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regenerateSecondaryKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regenerateSecondaryKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -291,21 +305,19 @@ def build_regenerate_secondary_key_request( "accessName": _SERIALIZER.url("access_name", access_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -317,10 +329,14 @@ def build_list_secrets_request( access_name: Union[str, "_models.AccessIdName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/listSecrets') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/listSecrets") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -328,45 +344,41 @@ def build_list_secrets_request( "accessName": _SERIALIZER.url("access_name", access_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TenantAccessOperations(object): - """TenantAccessOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantAccessOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`tenant_access` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -375,26 +387,32 @@ def list_by_service( service_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AccessInformationCollection"]: + ) -> Iterable[_models.AccessInformationCollection]: """Returns list of access infos - for Git and Management endpoints. :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: Not used. + :param filter: Not used. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessInformationCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.AccessInformationCollection] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AccessInformationCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessInformationCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -402,11 +420,14 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -414,11 +435,14 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -432,7 +456,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -446,7 +474,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant"} # type: ignore @distributed_trace def get_entity_tag( @@ -463,17 +491,22 @@ def get_entity_tag( :param service_name: The name of the API Management service. :type service_name: str :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: bool, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -481,12 +514,19 @@ def get_entity_tag( service_name=service_name, subscription_id=self._config.subscription_id, access_name=access_name, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -502,7 +542,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}"} # type: ignore @distributed_trace @@ -512,7 +552,7 @@ def get( service_name: str, access_name: Union[str, "_models.AccessIdName"], **kwargs: Any - ) -> "_models.AccessInformationContract": + ) -> _models.AccessInformationContract: """Get tenant access information details without secrets. :param resource_group_name: The name of the resource group. @@ -520,17 +560,22 @@ def get( :param service_name: The name of the API Management service. :type service_name: str :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessInformationContract, or the result of cls(response) - :rtype: ~api_management_client.models.AccessInformationContract + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessInformationContract] request = build_get_request( @@ -538,12 +583,19 @@ def get( service_name=service_name, subscription_id=self._config.subscription_id, access_name=access_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -561,7 +613,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}"} # type: ignore @distributed_trace @@ -571,9 +623,9 @@ def create( service_name: str, access_name: Union[str, "_models.AccessIdName"], if_match: str, - parameters: "_models.AccessInformationCreateParameters", + parameters: _models.AccessInformationCreateParameters, **kwargs: Any - ) -> "_models.AccessInformationContract": + ) -> _models.AccessInformationContract: """Update tenant access information details. :param resource_group_name: The name of the resource group. @@ -581,24 +633,28 @@ def create( :param service_name: The name of the API Management service. :type service_name: str :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Parameters supplied to retrieve the Tenant Access Information. - :type parameters: ~api_management_client.models.AccessInformationCreateParameters + :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessInformationContract, or the result of cls(response) - :rtype: ~api_management_client.models.AccessInformationContract + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessInformationContract] _json = self._serialize.body(parameters, 'AccessInformationCreateParameters') @@ -607,15 +663,22 @@ def create( service_name=service_name, access_name=access_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -633,7 +696,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}"} # type: ignore @distributed_trace @@ -643,9 +706,9 @@ def update( service_name: str, access_name: Union[str, "_models.AccessIdName"], if_match: str, - parameters: "_models.AccessInformationUpdateParameters", + parameters: _models.AccessInformationUpdateParameters, **kwargs: Any - ) -> "_models.AccessInformationContract": + ) -> _models.AccessInformationContract: """Update tenant access information details. :param resource_group_name: The name of the resource group. @@ -653,24 +716,28 @@ def update( :param service_name: The name of the API Management service. :type service_name: str :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName :param if_match: ETag of the Entity. ETag should match the current entity state from the header response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Parameters supplied to retrieve the Tenant Access Information. - :type parameters: ~api_management_client.models.AccessInformationUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessInformationContract, or the result of cls(response) - :rtype: ~api_management_client.models.AccessInformationContract + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessInformationContract] _json = self._serialize.body(parameters, 'AccessInformationUpdateParameters') @@ -679,15 +746,22 @@ def update( service_name=service_name, access_name=access_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -705,11 +779,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}"} # type: ignore @distributed_trace - def regenerate_primary_key( + def regenerate_primary_key( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -723,17 +797,22 @@ def regenerate_primary_key( :param service_name: The name of the API Management service. :type service_name: str :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_regenerate_primary_key_request( @@ -741,12 +820,19 @@ def regenerate_primary_key( service_name=service_name, subscription_id=self._config.subscription_id, access_name=access_name, + api_version=api_version, template_url=self.regenerate_primary_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -757,11 +843,11 @@ def regenerate_primary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_primary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regeneratePrimaryKey'} # type: ignore + regenerate_primary_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regeneratePrimaryKey"} # type: ignore @distributed_trace - def regenerate_secondary_key( + def regenerate_secondary_key( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -775,17 +861,22 @@ def regenerate_secondary_key( :param service_name: The name of the API Management service. :type service_name: str :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_regenerate_secondary_key_request( @@ -793,12 +884,19 @@ def regenerate_secondary_key( service_name=service_name, subscription_id=self._config.subscription_id, access_name=access_name, + api_version=api_version, template_url=self.regenerate_secondary_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -809,7 +907,7 @@ def regenerate_secondary_key( if cls: return cls(pipeline_response, None, {}) - regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regenerateSecondaryKey'} # type: ignore + regenerate_secondary_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regenerateSecondaryKey"} # type: ignore @distributed_trace @@ -819,7 +917,7 @@ def list_secrets( service_name: str, access_name: Union[str, "_models.AccessIdName"], **kwargs: Any - ) -> "_models.AccessInformationSecretsContract": + ) -> _models.AccessInformationSecretsContract: """Get tenant access information details. :param resource_group_name: The name of the resource group. @@ -827,17 +925,22 @@ def list_secrets( :param service_name: The name of the API Management service. :type service_name: str :param access_name: The identifier of the Access configuration. - :type access_name: str or ~api_management_client.models.AccessIdName + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessInformationSecretsContract, or the result of cls(response) - :rtype: ~api_management_client.models.AccessInformationSecretsContract + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationSecretsContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessInformationSecretsContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessInformationSecretsContract] request = build_list_secrets_request( @@ -845,12 +948,19 @@ def list_secrets( service_name=service_name, subscription_id=self._config.subscription_id, access_name=access_name, + api_version=api_version, template_url=self.list_secrets.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -868,5 +978,5 @@ def list_secrets( return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/listSecrets'} # type: ignore + list_secrets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/listSecrets"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_configuration_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_configuration_operations.py index bf95e864c0f7..5758d017280a 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_configuration_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_configuration_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -15,14 +16,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -34,16 +34,19 @@ def build_deploy_request_initial( subscription_id: str, configuration_name: Union[str, "_models.ConfigurationIdName"], *, - json: JSONType = None, + json: Optional[_models.DeployConfigurationParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -51,23 +54,21 @@ def build_deploy_request_initial( "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,16 +81,19 @@ def build_save_request_initial( subscription_id: str, configuration_name: Union[str, "_models.ConfigurationIdName"], *, - json: JSONType = None, + json: Optional[_models.SaveConfigurationParameter] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -97,23 +101,21 @@ def build_save_request_initial( "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,16 +128,19 @@ def build_validate_request_initial( subscription_id: str, configuration_name: Union[str, "_models.ConfigurationIdName"], *, - json: JSONType = None, + json: Optional[_models.DeployConfigurationParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -143,23 +148,21 @@ def build_validate_request_initial( "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -173,10 +176,14 @@ def build_get_sync_state_request( configuration_name: Union[str, "_models.ConfigurationIdName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/syncState') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/syncState") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -184,61 +191,61 @@ def build_get_sync_state_request( "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TenantConfigurationOperations(object): - """TenantConfigurationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantConfigurationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`tenant_configuration` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _deploy_initial( self, resource_group_name: str, service_name: str, configuration_name: Union[str, "_models.ConfigurationIdName"], - parameters: "_models.DeployConfigurationParameters", + parameters: _models.DeployConfigurationParameters, **kwargs: Any - ) -> Optional["_models.OperationResultContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResultContract"]] + ) -> Optional[_models.OperationResultContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationResultContract]] _json = self._serialize.body(parameters, 'DeployConfigurationParameters') @@ -247,14 +254,21 @@ def _deploy_initial( service_name=service_name, subscription_id=self._config.subscription_id, configuration_name=configuration_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._deploy_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -270,7 +284,7 @@ def _deploy_initial( return deserialized - _deploy_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy'} # type: ignore + _deploy_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy"} # type: ignore @distributed_trace @@ -279,9 +293,9 @@ def begin_deploy( resource_group_name: str, service_name: str, configuration_name: Union[str, "_models.ConfigurationIdName"], - parameters: "_models.DeployConfigurationParameters", + parameters: _models.DeployConfigurationParameters, **kwargs: Any - ) -> LROPoller["_models.OperationResultContract"]: + ) -> LROPoller[_models.OperationResultContract]: """This operation applies changes from the specified Git branch to the configuration database. This is a long running operation and could take several minutes to complete. @@ -290,9 +304,9 @@ def begin_deploy( :param service_name: The name of the API Management service. :type service_name: str :param configuration_name: The identifier of the Git Configuration Operation. - :type configuration_name: str or ~api_management_client.models.ConfigurationIdName + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName :param parameters: Deploy Configuration parameters. - :type parameters: ~api_management_client.models.DeployConfigurationParameters + :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 @@ -303,39 +317,51 @@ def begin_deploy( Retry-After header is present. :return: An instance of LROPoller that returns either OperationResultContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.OperationResultContract] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResultContract"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationResultContract] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._deploy_initial( + raw_result = self._deploy_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, configuration_name=configuration_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -344,26 +370,29 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_deploy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy'} # type: ignore + begin_deploy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy"} # type: ignore def _save_initial( self, resource_group_name: str, service_name: str, configuration_name: Union[str, "_models.ConfigurationIdName"], - parameters: "_models.SaveConfigurationParameter", + parameters: _models.SaveConfigurationParameter, **kwargs: Any - ) -> Optional["_models.OperationResultContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResultContract"]] + ) -> Optional[_models.OperationResultContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationResultContract]] _json = self._serialize.body(parameters, 'SaveConfigurationParameter') @@ -372,14 +401,21 @@ def _save_initial( service_name=service_name, subscription_id=self._config.subscription_id, configuration_name=configuration_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._save_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -395,7 +431,7 @@ def _save_initial( return deserialized - _save_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save'} # type: ignore + _save_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save"} # type: ignore @distributed_trace @@ -404,9 +440,9 @@ def begin_save( resource_group_name: str, service_name: str, configuration_name: Union[str, "_models.ConfigurationIdName"], - parameters: "_models.SaveConfigurationParameter", + parameters: _models.SaveConfigurationParameter, **kwargs: Any - ) -> LROPoller["_models.OperationResultContract"]: + ) -> LROPoller[_models.OperationResultContract]: """This operation creates a commit with the current configuration snapshot to the specified branch in the repository. This is a long running operation and could take several minutes to complete. @@ -415,9 +451,9 @@ def begin_save( :param service_name: The name of the API Management service. :type service_name: str :param configuration_name: The identifier of the Git Configuration Operation. - :type configuration_name: str or ~api_management_client.models.ConfigurationIdName + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName :param parameters: Save Configuration parameters. - :type parameters: ~api_management_client.models.SaveConfigurationParameter + :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 @@ -428,39 +464,51 @@ def begin_save( Retry-After header is present. :return: An instance of LROPoller that returns either OperationResultContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.OperationResultContract] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResultContract"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationResultContract] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._save_initial( + raw_result = self._save_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, configuration_name=configuration_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -469,26 +517,29 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_save.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save'} # type: ignore + begin_save.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save"} # type: ignore def _validate_initial( self, resource_group_name: str, service_name: str, configuration_name: Union[str, "_models.ConfigurationIdName"], - parameters: "_models.DeployConfigurationParameters", + parameters: _models.DeployConfigurationParameters, **kwargs: Any - ) -> Optional["_models.OperationResultContract"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResultContract"]] + ) -> Optional[_models.OperationResultContract]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationResultContract]] _json = self._serialize.body(parameters, 'DeployConfigurationParameters') @@ -497,14 +548,21 @@ def _validate_initial( service_name=service_name, subscription_id=self._config.subscription_id, configuration_name=configuration_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._validate_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -520,7 +578,7 @@ def _validate_initial( return deserialized - _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate'} # type: ignore + _validate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate"} # type: ignore @distributed_trace @@ -529,9 +587,9 @@ def begin_validate( resource_group_name: str, service_name: str, configuration_name: Union[str, "_models.ConfigurationIdName"], - parameters: "_models.DeployConfigurationParameters", + parameters: _models.DeployConfigurationParameters, **kwargs: Any - ) -> LROPoller["_models.OperationResultContract"]: + ) -> LROPoller[_models.OperationResultContract]: """This operation validates the changes in the specified Git branch. This is a long running operation and could take several minutes to complete. @@ -540,9 +598,9 @@ def begin_validate( :param service_name: The name of the API Management service. :type service_name: str :param configuration_name: The identifier of the Git Configuration Operation. - :type configuration_name: str or ~api_management_client.models.ConfigurationIdName + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName :param parameters: Validate Configuration parameters. - :type parameters: ~api_management_client.models.DeployConfigurationParameters + :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 @@ -553,39 +611,51 @@ def begin_validate( Retry-After header is present. :return: An instance of LROPoller that returns either OperationResultContract or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~api_management_client.models.OperationResultContract] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResultContract"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationResultContract] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._validate_initial( + raw_result = self._validate_initial( # type: ignore resource_group_name=resource_group_name, service_name=service_name, configuration_name=configuration_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', 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 - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -594,10 +664,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate'} # type: ignore + begin_validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate"} # type: ignore @distributed_trace def get_sync_state( @@ -606,7 +675,7 @@ def get_sync_state( service_name: str, configuration_name: Union[str, "_models.ConfigurationIdName"], **kwargs: Any - ) -> "_models.TenantConfigurationSyncStateContract": + ) -> _models.TenantConfigurationSyncStateContract: """Gets the status of the most recent synchronization between the configuration database and the Git repository. @@ -615,17 +684,22 @@ def get_sync_state( :param service_name: The name of the API Management service. :type service_name: str :param configuration_name: The identifier of the Git Configuration Operation. - :type configuration_name: str or ~api_management_client.models.ConfigurationIdName + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName :keyword callable cls: A custom type or function that will be passed the direct response :return: TenantConfigurationSyncStateContract, or the result of cls(response) - :rtype: ~api_management_client.models.TenantConfigurationSyncStateContract + :rtype: ~azure.mgmt.apimanagement.models.TenantConfigurationSyncStateContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantConfigurationSyncStateContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TenantConfigurationSyncStateContract] request = build_get_sync_state_request( @@ -633,12 +707,19 @@ def get_sync_state( service_name=service_name, subscription_id=self._config.subscription_id, configuration_name=configuration_name, + api_version=api_version, template_url=self.get_sync_state.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -653,5 +734,5 @@ def get_sync_state( return deserialized - get_sync_state.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/syncState'} # type: ignore + get_sync_state.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/syncState"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_settings_operations.py index 240f808226a3..b42739634b8f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_settings_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -34,33 +35,35 @@ def build_list_by_service_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -72,10 +75,14 @@ def build_get_request( settings_type: Union[str, "_models.SettingsTypeName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings/{settingsType}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings/{settingsType}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -83,45 +90,41 @@ def build_get_request( "settingsType": _SERIALIZER.url("settings_type", settings_type, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TenantSettingsOperations(object): - """TenantSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`tenant_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -130,26 +133,31 @@ def list_by_service( service_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.TenantSettingsCollection"]: + ) -> Iterable[_models.TenantSettingsCollection]: """Public settings. :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: Not used. + :param filter: Not used. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TenantSettingsCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.TenantSettingsCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TenantSettingsCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantSettingsCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TenantSettingsCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -157,11 +165,14 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -169,11 +180,14 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -187,7 +201,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -201,7 +219,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings"} # type: ignore @distributed_trace def get( @@ -210,7 +228,7 @@ def get( service_name: str, settings_type: Union[str, "_models.SettingsTypeName"], **kwargs: Any - ) -> "_models.TenantSettingsContract": + ) -> _models.TenantSettingsContract: """Get tenant settings. :param resource_group_name: The name of the resource group. @@ -218,17 +236,22 @@ def get( :param service_name: The name of the API Management service. :type service_name: str :param settings_type: The identifier of the settings. - :type settings_type: str or ~api_management_client.models.SettingsTypeName + :type settings_type: str or ~azure.mgmt.apimanagement.models.SettingsTypeName :keyword callable cls: A custom type or function that will be passed the direct response :return: TenantSettingsContract, or the result of cls(response) - :rtype: ~api_management_client.models.TenantSettingsContract + :rtype: ~azure.mgmt.apimanagement.models.TenantSettingsContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantSettingsContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TenantSettingsContract] request = build_get_request( @@ -236,12 +259,19 @@ def get( service_name=service_name, subscription_id=self._config.subscription_id, settings_type=settings_type, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -259,5 +289,5 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings/{settingsType}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings/{settingsType}"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_confirmation_password_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_confirmation_password_operations.py index 2855d8e39ae5..ab7480d31d53 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_confirmation_password_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_confirmation_password_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,20 +6,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 typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -34,10 +35,14 @@ def build_send_request( app_type: Optional[Union[str, "_models.AppType"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/confirmations/password/send') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/confirmations/password/send") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -45,50 +50,46 @@ def build_send_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if app_type is not None: - query_parameters['appType'] = _SERIALIZER.query("app_type", app_type, 'str') + _params['appType'] = _SERIALIZER.query("app_type", app_type, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UserConfirmationPasswordOperations(object): - """UserConfirmationPasswordOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UserConfirmationPasswordOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`user_confirmation_password` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace - def send( + def send( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -106,17 +107,22 @@ def send( :type user_id: str :param app_type: Determines the type of application which send the create user request. Default is legacy publisher portal. - :type app_type: str or ~api_management_client.models.AppType + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_send_request( @@ -124,13 +130,20 @@ def send( service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, app_type=app_type, template_url=self.send.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -141,5 +154,5 @@ def send( if cls: return cls(pipeline_response, None, {}) - send.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/confirmations/password/send'} # type: ignore + send.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/confirmations/password/send"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_group_operations.py index 258e61fc4721..243a106f8147 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_group_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_group_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -37,10 +38,14 @@ def build_list_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/groups') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/groups") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -48,51 +53,47 @@ def build_list_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UserGroupOperations(object): - """UserGroupOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UserGroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`user_group` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -104,7 +105,7 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.GroupCollection"]: + ) -> Iterable[_models.GroupCollection]: """Lists all user groups. :param resource_group_name: The name of the resource group. @@ -119,22 +120,27 @@ def list( filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
. + endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GroupCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.GroupCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GroupCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GroupCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -143,13 +149,16 @@ def prepare_request(next_link=None): service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -158,13 +167,16 @@ def prepare_request(next_link=None): service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -178,7 +190,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -192,4 +208,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/groups'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/groups"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_identities_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_identities_operations.py index 6b528b83a6bc..c948b30d6344 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_identities_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_identities_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -33,10 +34,14 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/identities') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/identities") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -44,45 +49,41 @@ def build_list_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UserIdentitiesOperations(object): - """UserIdentitiesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UserIdentitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`user_identities` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -91,7 +92,7 @@ def list( service_name: str, user_id: str, **kwargs: Any - ) -> Iterable["_models.UserIdentityCollection"]: + ) -> Iterable[_models.UserIdentityCollection]: """List of all user identities. :param resource_group_name: The name of the resource group. @@ -103,14 +104,19 @@ def list( :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.paging.ItemPaged[~api_management_client.models.UserIdentityCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.UserIdentityCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserIdentityCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserIdentityCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -119,10 +125,13 @@ def prepare_request(next_link=None): service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -131,10 +140,13 @@ def prepare_request(next_link=None): service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -148,7 +160,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -162,4 +178,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/identities'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/identities"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_operations.py index 5a8c2937b9a4..5208bf3aafe4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -38,39 +38,41 @@ def build_list_by_service_request( expand_groups: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) if expand_groups is not None: - query_parameters['expandGroups'] = _SERIALIZER.query("expand_groups", expand_groups, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['expandGroups'] = _SERIALIZER.query("expand_groups", expand_groups, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -82,10 +84,14 @@ def build_get_entity_tag_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -93,21 +99,19 @@ def build_get_entity_tag_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -119,10 +123,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -130,21 +138,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -155,18 +161,21 @@ def build_create_or_update_request( user_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.UserCreateParameters] = None, content: Any = None, notify: Optional[bool] = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -174,27 +183,25 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if notify is not None: - query_parameters['notify'] = _SERIALIZER.query("notify", notify, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['notify'] = _SERIALIZER.query("notify", notify, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -208,16 +215,19 @@ def build_update_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.UserUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -225,24 +235,22 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -261,10 +269,14 @@ def build_delete_request( app_type: Optional[Union[str, "_models.AppType"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -272,28 +284,26 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if delete_subscriptions is not None: - query_parameters['deleteSubscriptions'] = _SERIALIZER.query("delete_subscriptions", delete_subscriptions, 'bool') + _params['deleteSubscriptions'] = _SERIALIZER.query("delete_subscriptions", delete_subscriptions, 'bool') if notify is not None: - query_parameters['notify'] = _SERIALIZER.query("notify", notify, 'bool') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['notify'] = _SERIALIZER.query("notify", notify, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if app_type is not None: - query_parameters['appType'] = _SERIALIZER.query("app_type", app_type, 'str') + _params['appType'] = _SERIALIZER.query("app_type", app_type, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -305,10 +315,14 @@ def build_generate_sso_url_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/generateSsoUrl') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/generateSsoUrl") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -316,21 +330,19 @@ def build_generate_sso_url_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -341,16 +353,19 @@ def build_get_shared_access_token_request( user_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.UserTokenParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/token') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/token") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -358,49 +373,45 @@ def build_get_shared_access_token_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class UserOperations(object): - """UserOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UserOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`user` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_service( @@ -412,7 +423,7 @@ def list_by_service( skip: Optional[int] = None, expand_groups: Optional[bool] = None, **kwargs: Any - ) -> Iterable["_models.UserCollection"]: + ) -> Iterable[_models.UserCollection]: """Lists a collection of registered users in the specified service instance. :param resource_group_name: The name of the resource group. @@ -427,24 +438,29 @@ def list_by_service( |
| email | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| state | filter | eq | |
| registrationDate | filter | ge, le, eq, ne, gt, lt | |
| note | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
| groups | expand | | |
. + |
| groups | expand | | |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int - :param expand_groups: Detailed Group in response. + :param expand_groups: Detailed Group in response. Default value is None. :type expand_groups: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either UserCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.UserCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.UserCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -452,14 +468,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, expand_groups=expand_groups, template_url=self.list_by_service.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -467,14 +486,17 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, service_name=service_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, expand_groups=expand_groups, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -488,7 +510,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -502,7 +528,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users'} # type: ignore + list_by_service.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users"} # type: ignore @distributed_trace def get_entity_tag( @@ -525,11 +551,16 @@ def get_entity_tag( :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_get_entity_tag_request( @@ -537,12 +568,19 @@ def get_entity_tag( service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_entity_tag.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -558,7 +596,7 @@ def get_entity_tag( return cls(pipeline_response, None, response_headers) return 200 <= response.status_code <= 299 - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore + get_entity_tag.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # type: ignore @distributed_trace @@ -568,7 +606,7 @@ def get( service_name: str, user_id: str, **kwargs: Any - ) -> "_models.UserContract": + ) -> _models.UserContract: """Gets the details of the user specified by its identifier. :param resource_group_name: The name of the resource group. @@ -579,14 +617,19 @@ def get( :type user_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: UserContract, or the result of cls(response) - :rtype: ~api_management_client.models.UserContract + :rtype: ~azure.mgmt.apimanagement.models.UserContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserContract] request = build_get_request( @@ -594,12 +637,19 @@ def get( service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -617,7 +667,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # type: ignore @distributed_trace @@ -626,11 +676,11 @@ def create_or_update( resource_group_name: str, service_name: str, user_id: str, - parameters: "_models.UserCreateParameters", + parameters: _models.UserCreateParameters, notify: Optional[bool] = None, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.UserContract": + ) -> _models.UserContract: """Creates or Updates a user. :param resource_group_name: The name of the resource group. @@ -640,24 +690,28 @@ def create_or_update( :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str :param parameters: Create or update parameters. - :type parameters: ~api_management_client.models.UserCreateParameters - :param notify: Send an Email notification to the User. + :type parameters: ~azure.mgmt.apimanagement.models.UserCreateParameters + :param notify: Send an Email notification to the User. Default value is None. :type notify: bool :param if_match: ETag of the Entity. Not required when creating an entity, but required when - updating an entity. + updating an entity. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :return: UserContract, or the result of cls(response) - :rtype: ~api_management_client.models.UserContract + :rtype: ~azure.mgmt.apimanagement.models.UserContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserContract] _json = self._serialize.body(parameters, 'UserCreateParameters') @@ -666,16 +720,23 @@ def create_or_update( service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, notify=notify, if_match=if_match, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -699,7 +760,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # type: ignore @distributed_trace @@ -709,9 +770,9 @@ def update( service_name: str, user_id: str, if_match: str, - parameters: "_models.UserUpdateParameters", + parameters: _models.UserUpdateParameters, **kwargs: Any - ) -> "_models.UserContract": + ) -> _models.UserContract: """Updates the details of the user specified by its identifier. :param resource_group_name: The name of the resource group. @@ -724,19 +785,23 @@ def update( response of the GET request or it should be * for unconditional update. :type if_match: str :param parameters: Update parameters. - :type parameters: ~api_management_client.models.UserUpdateParameters + :type parameters: ~azure.mgmt.apimanagement.models.UserUpdateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: UserContract, or the result of cls(response) - :rtype: ~api_management_client.models.UserContract + :rtype: ~azure.mgmt.apimanagement.models.UserContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserContract] _json = self._serialize.body(parameters, 'UserUpdateParameters') @@ -745,15 +810,22 @@ def update( service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -771,11 +843,11 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_name: str, @@ -797,23 +869,29 @@ def delete( :param if_match: ETag of 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 - :param delete_subscriptions: Whether to delete user's subscription or not. + :param delete_subscriptions: Whether to delete user's subscription or not. Default value is + None. :type delete_subscriptions: bool - :param notify: Send an Account Closed Email notification to the User. + :param notify: Send an Account Closed Email notification to the User. Default value is None. :type notify: bool :param app_type: Determines the type of application which send the create user request. Default is legacy publisher portal. - :type app_type: str or ~api_management_client.models.AppType + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -821,16 +899,23 @@ def delete( service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, delete_subscriptions=delete_subscriptions, notify=notify, app_type=app_type, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -841,7 +926,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}"} # type: ignore @distributed_trace @@ -851,7 +936,7 @@ def generate_sso_url( service_name: str, user_id: str, **kwargs: Any - ) -> "_models.GenerateSsoUrlResult": + ) -> _models.GenerateSsoUrlResult: """Retrieves a redirection URL containing an authentication token for signing a given user into the developer portal. @@ -863,14 +948,19 @@ def generate_sso_url( :type user_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GenerateSsoUrlResult, or the result of cls(response) - :rtype: ~api_management_client.models.GenerateSsoUrlResult + :rtype: ~azure.mgmt.apimanagement.models.GenerateSsoUrlResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateSsoUrlResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GenerateSsoUrlResult] request = build_generate_sso_url_request( @@ -878,12 +968,19 @@ def generate_sso_url( service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.generate_sso_url.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -898,7 +995,7 @@ def generate_sso_url( return deserialized - generate_sso_url.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/generateSsoUrl'} # type: ignore + generate_sso_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/generateSsoUrl"} # type: ignore @distributed_trace @@ -907,9 +1004,9 @@ def get_shared_access_token( resource_group_name: str, service_name: str, user_id: str, - parameters: "_models.UserTokenParameters", + parameters: _models.UserTokenParameters, **kwargs: Any - ) -> "_models.UserTokenResult": + ) -> _models.UserTokenResult: """Gets the Shared Access Authorization Token for the User. :param resource_group_name: The name of the resource group. @@ -919,19 +1016,23 @@ def get_shared_access_token( :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str :param parameters: Create Authorization Token parameters. - :type parameters: ~api_management_client.models.UserTokenParameters + :type parameters: ~azure.mgmt.apimanagement.models.UserTokenParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: UserTokenResult, or the result of cls(response) - :rtype: ~api_management_client.models.UserTokenResult + :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserTokenResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.UserTokenResult] _json = self._serialize.body(parameters, 'UserTokenParameters') @@ -940,14 +1041,21 @@ def get_shared_access_token( service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.get_shared_access_token.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -962,5 +1070,5 @@ def get_shared_access_token( return deserialized - get_shared_access_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/token'} # type: ignore + get_shared_access_token.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/token"} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_subscription_operations.py index 804a840b6405..c11453de5cf7 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_subscription_operations.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_subscription_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,11 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -37,10 +38,14 @@ def build_list_request( skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -48,27 +53,25 @@ def build_list_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skip is not None: - query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', minimum=0) + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -81,10 +84,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions/{sid}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions/{sid}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), @@ -93,45 +100,41 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UserSubscriptionOperations(object): - """UserSubscriptionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UserSubscriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~api_management_client.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`user_subscription` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -143,7 +146,7 @@ def list( top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.SubscriptionCollection"]: + ) -> Iterable[_models.SubscriptionCollection]: """Lists the collection of subscriptions of the specified user. :param resource_group_name: The name of the resource group. @@ -161,23 +164,28 @@ def list( startswith, endswith |
|scope | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
|userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
|productId | filter | ge, le, eq, ne, gt, lt | substringof, - contains, startswith, endswith |
. + contains, startswith, endswith |
. Default value is None. :type filter: str - :param top: Number of records to return. + :param top: Number of records to return. Default value is None. :type top: int - :param skip: Number of records to skip. + :param skip: Number of records to skip. Default value is None. :type skip: int :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SubscriptionCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~api_management_client.models.SubscriptionCollection] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.SubscriptionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionCollection"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionCollection] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -186,13 +194,16 @@ def prepare_request(next_link=None): service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -201,13 +212,16 @@ def prepare_request(next_link=None): service_name=service_name, user_id=user_id, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, top=top, skip=skip, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -221,7 +235,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -235,7 +253,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions"} # type: ignore @distributed_trace def get( @@ -245,7 +263,7 @@ def get( user_id: str, sid: str, **kwargs: Any - ) -> "_models.SubscriptionContract": + ) -> _models.SubscriptionContract: """Gets the specified Subscription entity associated with a particular user. :param resource_group_name: The name of the resource group. @@ -259,14 +277,19 @@ def get( :type sid: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionContract, or the result of cls(response) - :rtype: ~api_management_client.models.SubscriptionContract + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionContract"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionContract] request = build_get_request( @@ -275,12 +298,19 @@ def get( user_id=user_id, sid=sid, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -298,5 +328,5 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions/{sid}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions/{sid}"} # type: ignore